Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable auto correct #359

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/fleather/lib/src/widgets/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ class FleatherEditor extends StatefulWidget {
/// Defaults to `false`. Must not be `null`.
final bool readOnly;

/// Whether to enable autocorrection.
///
/// Defaults to `true`.
final bool autocorrect;

/// Whether to enable user interface affordances for changing the
/// text selection.
///
Expand Down Expand Up @@ -283,6 +288,7 @@ class FleatherEditor extends StatefulWidget {
this.autofocus = false,
this.showCursor = true,
this.readOnly = false,
this.autocorrect = true,
this.enableInteractiveSelection = true,
this.minHeight,
this.maxHeight,
Expand Down Expand Up @@ -551,6 +557,7 @@ class RawEditor extends StatefulWidget {
this.autofocus = false,
bool? showCursor,
this.readOnly = false,
this.autocorrect = true,
this.enableInteractiveSelection = true,
this.minHeight,
this.maxHeight,
Expand Down Expand Up @@ -602,6 +609,11 @@ class RawEditor extends StatefulWidget {
/// Defaults to false. Must not be null.
final bool readOnly;

/// Whether to enable autocorrection.
///
/// Defaults to `true`.
final bool autocorrect;
simonbengtsson marked this conversation as resolved.
Show resolved Hide resolved

/// Callback which is triggered when the user wants to open a URL from
/// a link in the document.
final ValueChanged<String?>? onLaunchUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ mixin RawEditorStateTextInputClientMixin on EditorState
inputType: TextInputType.multiline,
readOnly: widget.readOnly,
obscureText: false,
autocorrect: false,
autocorrect: widget.autocorrect,
simonbengtsson marked this conversation as resolved.
Show resolved Hide resolved
enableDeltaModel: true,
inputAction: TextInputAction.newline,
keyboardAppearance: widget.keyboardAppearance,
Expand Down
7 changes: 7 additions & 0 deletions packages/fleather/lib/src/widgets/field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class FleatherField extends StatefulWidget {
/// Defaults to `false`. Must not be `null`.
final bool readOnly;

/// Whether to enable autocorrection.
///
/// Defaults to `true`.
final bool autocorrect;

/// Whether to enable user interface affordances for changing the
/// text selection.
///
Expand Down Expand Up @@ -175,6 +180,7 @@ class FleatherField extends StatefulWidget {
this.autofocus = false,
this.showCursor = true,
this.readOnly = false,
this.autocorrect = true,
this.enableInteractiveSelection = true,
this.minHeight,
this.maxHeight,
Expand Down Expand Up @@ -245,6 +251,7 @@ class _FleatherFieldState extends State<FleatherField> {
autofocus: widget.autofocus,
showCursor: widget.showCursor,
readOnly: widget.readOnly,
autocorrect: widget.autocorrect,
enableInteractiveSelection: widget.enableInteractiveSelection,
minHeight: widget.minHeight,
maxHeight: widget.maxHeight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ void main() {
style: const TextStyle(), spacing: const VerticalSpacing())));
when(() => rawEditor.controller).thenReturn(controller);
when(() => rawEditor.readOnly).thenReturn(false);
when(() => rawEditor.autocorrect).thenReturn(true);
when(() => rawEditor.keyboardAppearance).thenReturn(Brightness.light);
when(() => rawEditor.textCapitalization)
.thenReturn(TextCapitalization.none);
Expand Down
Loading