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

[SuperTextField] - Create a controller that supports undo/redo (Resolves #189) #704

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:attributed_text/attributed_text.dart';
import 'package:flutter/services.dart';

/// The logical value of a text editable that displays attributed
/// text.
class AttributedTextEditingValue {
factory AttributedTextEditingValue.empty() => AttributedTextEditingValue(
text: AttributedText(text: ""),
);

factory AttributedTextEditingValue.emptyWithCaret() => AttributedTextEditingValue(
text: AttributedText(text: ""),
selection: const TextSelection.collapsed(offset: 0),
);

const AttributedTextEditingValue({
required this.text,
this.selection = const TextSelection.collapsed(offset: -1),
this.composingRegion = TextRange.empty,
});

/// The text displayed in the editable.
final AttributedText text;

/// The text selection in the editable.
///
/// A [selection] of `TextSelection.collapsed(offset: -1)` represents
/// the absence of a selection.
final TextSelection selection;

/// The region of [text] that's currently being composed.
///
/// Composing regions are used by operating system input method
/// engines (IMEs) to create compound characters, check spelling,
/// and apply other effects on the platform side.
final TextRange composingRegion;
}
Loading