Follow dart best practices by using and remove as well since they are not used

pull/1506/head
Ellet 1 year ago
parent b6fe4ade55
commit 0d38e8787d
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 3
      CHANGELOG.md
  2. 3
      analysis_options.yaml
  3. 10
      example/lib/pages/home_page.dart
  4. 2
      flutter_quill_extensions/analysis_options.yaml
  5. 2
      flutter_quill_extensions/pubspec.yaml
  6. 62
      lib/src/models/documents/attribute.dart
  7. 16
      lib/src/models/documents/document.dart
  8. 4
      lib/src/models/documents/history.dart
  9. 8
      lib/src/models/documents/nodes/container.dart
  10. 4
      lib/src/models/documents/nodes/embeddable.dart
  11. 6
      lib/src/models/documents/nodes/leaf.dart
  12. 36
      lib/src/models/documents/nodes/line.dart
  13. 6
      lib/src/models/documents/style.dart
  14. 20
      lib/src/models/quill_delta.dart
  15. 2
      lib/src/models/rules/delete.dart
  16. 6
      lib/src/models/rules/format.dart
  17. 2
      lib/src/models/rules/insert.dart
  18. 2
      lib/src/models/rules/rule.dart
  19. 2
      lib/src/utils/embeds.dart
  20. 30
      lib/src/utils/string.dart
  21. 16
      lib/src/widgets/controller.dart
  22. 16
      lib/src/widgets/default_styles.dart
  23. 26
      lib/src/widgets/editor/editor.dart
  24. 8
      lib/src/widgets/keyboard_listener.dart
  25. 6
      lib/src/widgets/link.dart
  26. 27
      lib/src/widgets/proxy.dart
  27. 5
      lib/src/widgets/quill_single_child_scroll_view.dart
  28. 36
      lib/src/widgets/raw_editor/raw_editor.dart
  29. 6
      lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart
  30. 2
      lib/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart
  31. 4
      lib/src/widgets/style_widgets/bullet_point.dart
  32. 6
      lib/src/widgets/style_widgets/checkbox_point.dart
  33. 13
      lib/src/widgets/text_block.dart
  34. 6
      lib/src/widgets/text_line.dart
  35. 56
      lib/src/widgets/text_selection.dart
  36. 6
      lib/src/widgets/toolbar/buttons/arrow_indicated_list.dart
  37. 5
      lib/src/widgets/toolbar/buttons/color.dart
  38. 6
      lib/src/widgets/toolbar/buttons/font_family.dart
  39. 6
      lib/src/widgets/toolbar/buttons/font_size.dart
  40. 6
      lib/src/widgets/toolbar/buttons/history.dart
  41. 6
      lib/src/widgets/toolbar/buttons/indent.dart
  42. 8
      lib/src/widgets/toolbar/buttons/link_style.dart
  43. 2
      lib/src/widgets/toolbar/buttons/link_style2.dart
  44. 4
      lib/src/widgets/toolbar/buttons/quill_icon.dart
  45. 8
      lib/src/widgets/toolbar/buttons/search/search_dialog.dart
  46. 39
      lib/src/widgets/toolbar/buttons/select_alignment.dart
  47. 10
      lib/src/widgets/toolbar/buttons/select_header_style.dart
  48. 6
      lib/src/widgets/toolbar/buttons/toggle_check_list.dart
  49. 6
      lib/src/widgets/toolbar/buttons/toggle_style.dart
  50. 9
      pubspec.yaml
  51. 34
      test/widgets/controller_test.dart

@ -1,3 +1,6 @@
## [8.1.11]
- Follow dart best practices by using `lints` and remove `pedantic` as well `platform` since they are not used
## [8.1.10] ## [8.1.10]
- Secret for automated publishing to pub.dev. - Secret for automated publishing to pub.dev.

@ -1,4 +1,5 @@
include: package:pedantic/analysis_options.yaml include: package:lints/recommended.yaml
# include: package:pedantic/analysis_options.yaml
analyzer: analyzer:
errors: errors:

@ -166,7 +166,7 @@ class _HomePageState extends State<HomePage> {
extentOffset: offset + length, extentOffset: offset + length,
); );
controller.updateSelection(selection, ChangeSource.REMOTE); controller.updateSelection(selection, ChangeSource.remote);
// _selectionType = _SelectionType.line; // _selectionType = _SelectionType.line;
@ -539,7 +539,7 @@ class _HomePageState extends State<HomePage> {
TextSelection.collapsed( TextSelection.collapsed(
offset: controller.selection.extentOffset + 1, offset: controller.selection.extentOffset + 1,
), ),
ChangeSource.LOCAL, ChangeSource.local,
); );
controller.document.insert( controller.document.insert(
@ -551,7 +551,7 @@ class _HomePageState extends State<HomePage> {
TextSelection.collapsed( TextSelection.collapsed(
offset: controller.selection.extentOffset + 1, offset: controller.selection.extentOffset + 1,
), ),
ChangeSource.LOCAL, ChangeSource.local,
); );
controller.document.insert(controller.selection.extentOffset, ' '); controller.document.insert(controller.selection.extentOffset, ' ');
@ -559,7 +559,7 @@ class _HomePageState extends State<HomePage> {
TextSelection.collapsed( TextSelection.collapsed(
offset: controller.selection.extentOffset + 1, offset: controller.selection.extentOffset + 1,
), ),
ChangeSource.LOCAL, ChangeSource.local,
); );
controller.document.insert(controller.selection.extentOffset, '\n'); controller.document.insert(controller.selection.extentOffset, '\n');
@ -567,7 +567,7 @@ class _HomePageState extends State<HomePage> {
TextSelection.collapsed( TextSelection.collapsed(
offset: controller.selection.extentOffset + 1, offset: controller.selection.extentOffset + 1,
), ),
ChangeSource.LOCAL, ChangeSource.local,
); );
} }
} }

@ -1,4 +1,4 @@
include: package:pedantic/analysis_options.yaml include: package:lints/recommended.yaml
analyzer: analyzer:
errors: errors:

@ -49,7 +49,7 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^3.0.0 flutter_lints: ^3.0.1
flutter: flutter:
uses-material-design: true uses-material-design: true

@ -4,10 +4,10 @@ import 'package:equatable/equatable.dart';
import 'package:quiver/core.dart'; import 'package:quiver/core.dart';
enum AttributeScope { enum AttributeScope {
INLINE, // refer to https://quilljs.com/docs/formats/#inline inline, // refer to https://quilljs.com/docs/formats/#inline
BLOCK, // refer to https://quilljs.com/docs/formats/#block block, // refer to https://quilljs.com/docs/formats/#block
EMBEDS, // refer to https://quilljs.com/docs/formats/#embeds embeds, // refer to https://quilljs.com/docs/formats/#embeds
IGNORE, // attributes that can be ignored ignore, // attributes that can be ignored
} }
class Attribute<T> extends Equatable { class Attribute<T> extends Equatable {
@ -227,7 +227,7 @@ class Attribute<T> extends Equatable {
return IndentAttribute(level: level); return IndentAttribute(level: level);
} }
bool get isInline => scope == AttributeScope.INLINE; bool get isInline => scope == AttributeScope.inline;
bool get isBlockExceptHeader => blockKeysExceptHeader.contains(key); bool get isBlockExceptHeader => blockKeysExceptHeader.contains(key);
@ -283,110 +283,110 @@ class Attribute<T> extends Equatable {
} }
class BoldAttribute extends Attribute<bool> { class BoldAttribute extends Attribute<bool> {
const BoldAttribute() : super('bold', AttributeScope.INLINE, true); const BoldAttribute() : super('bold', AttributeScope.inline, true);
} }
class ItalicAttribute extends Attribute<bool> { class ItalicAttribute extends Attribute<bool> {
const ItalicAttribute() : super('italic', AttributeScope.INLINE, true); const ItalicAttribute() : super('italic', AttributeScope.inline, true);
} }
class SmallAttribute extends Attribute<bool> { class SmallAttribute extends Attribute<bool> {
const SmallAttribute() : super('small', AttributeScope.INLINE, true); const SmallAttribute() : super('small', AttributeScope.inline, true);
} }
class UnderlineAttribute extends Attribute<bool> { class UnderlineAttribute extends Attribute<bool> {
const UnderlineAttribute() : super('underline', AttributeScope.INLINE, true); const UnderlineAttribute() : super('underline', AttributeScope.inline, true);
} }
class StrikeThroughAttribute extends Attribute<bool> { class StrikeThroughAttribute extends Attribute<bool> {
const StrikeThroughAttribute() : super('strike', AttributeScope.INLINE, true); const StrikeThroughAttribute() : super('strike', AttributeScope.inline, true);
} }
class InlineCodeAttribute extends Attribute<bool> { class InlineCodeAttribute extends Attribute<bool> {
const InlineCodeAttribute() : super('code', AttributeScope.INLINE, true); const InlineCodeAttribute() : super('code', AttributeScope.inline, true);
} }
class FontAttribute extends Attribute<String?> { class FontAttribute extends Attribute<String?> {
const FontAttribute(String? val) : super('font', AttributeScope.INLINE, val); const FontAttribute(String? val) : super('font', AttributeScope.inline, val);
} }
class SizeAttribute extends Attribute<String?> { class SizeAttribute extends Attribute<String?> {
const SizeAttribute(String? val) : super('size', AttributeScope.INLINE, val); const SizeAttribute(String? val) : super('size', AttributeScope.inline, val);
} }
class LinkAttribute extends Attribute<String?> { class LinkAttribute extends Attribute<String?> {
const LinkAttribute(String? val) : super('link', AttributeScope.INLINE, val); const LinkAttribute(String? val) : super('link', AttributeScope.inline, val);
} }
class ColorAttribute extends Attribute<String?> { class ColorAttribute extends Attribute<String?> {
const ColorAttribute(String? val) const ColorAttribute(String? val)
: super('color', AttributeScope.INLINE, val); : super('color', AttributeScope.inline, val);
} }
class BackgroundAttribute extends Attribute<String?> { class BackgroundAttribute extends Attribute<String?> {
const BackgroundAttribute(String? val) const BackgroundAttribute(String? val)
: super('background', AttributeScope.INLINE, val); : super('background', AttributeScope.inline, val);
} }
/// This is custom attribute for hint /// This is custom attribute for hint
class PlaceholderAttribute extends Attribute<bool> { class PlaceholderAttribute extends Attribute<bool> {
const PlaceholderAttribute() const PlaceholderAttribute()
: super('placeholder', AttributeScope.INLINE, true); : super('placeholder', AttributeScope.inline, true);
} }
class HeaderAttribute extends Attribute<int?> { class HeaderAttribute extends Attribute<int?> {
const HeaderAttribute({int? level}) const HeaderAttribute({int? level})
: super('header', AttributeScope.BLOCK, level); : super('header', AttributeScope.block, level);
} }
class IndentAttribute extends Attribute<int?> { class IndentAttribute extends Attribute<int?> {
const IndentAttribute({int? level}) const IndentAttribute({int? level})
: super('indent', AttributeScope.BLOCK, level); : super('indent', AttributeScope.block, level);
} }
class AlignAttribute extends Attribute<String?> { class AlignAttribute extends Attribute<String?> {
const AlignAttribute(String? val) : super('align', AttributeScope.BLOCK, val); const AlignAttribute(String? val) : super('align', AttributeScope.block, val);
} }
class ListAttribute extends Attribute<String?> { class ListAttribute extends Attribute<String?> {
const ListAttribute(String? val) : super('list', AttributeScope.BLOCK, val); const ListAttribute(String? val) : super('list', AttributeScope.block, val);
} }
class CodeBlockAttribute extends Attribute<bool> { class CodeBlockAttribute extends Attribute<bool> {
const CodeBlockAttribute() : super('code-block', AttributeScope.BLOCK, true); const CodeBlockAttribute() : super('code-block', AttributeScope.block, true);
} }
class BlockQuoteAttribute extends Attribute<bool> { class BlockQuoteAttribute extends Attribute<bool> {
const BlockQuoteAttribute() : super('blockquote', AttributeScope.BLOCK, true); const BlockQuoteAttribute() : super('blockquote', AttributeScope.block, true);
} }
class DirectionAttribute extends Attribute<String?> { class DirectionAttribute extends Attribute<String?> {
const DirectionAttribute(String? val) const DirectionAttribute(String? val)
: super('direction', AttributeScope.BLOCK, val); : super('direction', AttributeScope.block, val);
} }
class WidthAttribute extends Attribute<String?> { class WidthAttribute extends Attribute<String?> {
const WidthAttribute(String? val) const WidthAttribute(String? val)
: super('width', AttributeScope.IGNORE, val); : super('width', AttributeScope.ignore, val);
} }
class HeightAttribute extends Attribute<String?> { class HeightAttribute extends Attribute<String?> {
const HeightAttribute(String? val) const HeightAttribute(String? val)
: super('height', AttributeScope.IGNORE, val); : super('height', AttributeScope.ignore, val);
} }
class StyleAttribute extends Attribute<String?> { class StyleAttribute extends Attribute<String?> {
const StyleAttribute(String? val) const StyleAttribute(String? val)
: super('style', AttributeScope.IGNORE, val); : super('style', AttributeScope.ignore, val);
} }
class TokenAttribute extends Attribute<String> { class TokenAttribute extends Attribute<String> {
const TokenAttribute(String val) : super('token', AttributeScope.IGNORE, val); const TokenAttribute(String val) : super('token', AttributeScope.ignore, val);
} }
class ScriptAttribute extends Attribute<String?> { class ScriptAttribute extends Attribute<String?> {
ScriptAttribute(ScriptAttributes? val) ScriptAttribute(ScriptAttributes? val)
: super('script', AttributeScope.INLINE, val?.value); : super('script', AttributeScope.inline, val?.value);
} }
enum ScriptAttributes { enum ScriptAttributes {
@ -400,10 +400,10 @@ enum ScriptAttributes {
class ImageAttribute extends Attribute<String?> { class ImageAttribute extends Attribute<String?> {
const ImageAttribute(String? url) const ImageAttribute(String? url)
: super('image', AttributeScope.EMBEDS, url); : super('image', AttributeScope.embeds, url);
} }
class VideoAttribute extends Attribute<String?> { class VideoAttribute extends Attribute<String?> {
const VideoAttribute(String? url) const VideoAttribute(String? url)
: super('video', AttributeScope.EMBEDS, url); : super('video', AttributeScope.embeds, url);
} }

@ -78,9 +78,9 @@ class Document {
return Delta(); return Delta();
} }
final delta = _rules.apply(RuleType.INSERT, this, index, final delta = _rules.apply(RuleType.insert, this, index,
data: data, len: replaceLength); data: data, len: replaceLength);
compose(delta, ChangeSource.LOCAL); compose(delta, ChangeSource.local);
return delta; return delta;
} }
@ -92,9 +92,9 @@ class Document {
/// Returns an instance of [Delta] actually composed into this document. /// Returns an instance of [Delta] actually composed into this document.
Delta delete(int index, int len) { Delta delete(int index, int len) {
assert(index >= 0 && len > 0); assert(index >= 0 && len > 0);
final delta = _rules.apply(RuleType.DELETE, this, index, len: len); final delta = _rules.apply(RuleType.delete, this, index, len: len);
if (delta.isNotEmpty) { if (delta.isNotEmpty) {
compose(delta, ChangeSource.LOCAL); compose(delta, ChangeSource.local);
} }
return delta; return delta;
} }
@ -142,10 +142,10 @@ class Document {
var delta = Delta(); var delta = Delta();
final formatDelta = _rules.apply(RuleType.FORMAT, this, index, final formatDelta = _rules.apply(RuleType.format, this, index,
len: len, attribute: attribute); len: len, attribute: attribute);
if (formatDelta.isNotEmpty) { if (formatDelta.isNotEmpty) {
compose(formatDelta, ChangeSource.LOCAL); compose(formatDelta, ChangeSource.local);
delta = delta.compose(formatDelta); delta = delta.compose(formatDelta);
} }
@ -445,8 +445,8 @@ class Document {
/// Source of a [Change]. /// Source of a [Change].
enum ChangeSource { enum ChangeSource {
/// Change originated from a local action. Typically triggered by user. /// Change originated from a local action. Typically triggered by user.
LOCAL, local,
/// Change originated from a remote action. /// Change originated from a remote action.
REMOTE, remote,
} }

@ -34,7 +34,7 @@ class History {
void handleDocChange(DocChange docChange) { void handleDocChange(DocChange docChange) {
if (ignoreChange) return; if (ignoreChange) return;
if (!userOnly || docChange.source == ChangeSource.LOCAL) { if (!userOnly || docChange.source == ChangeSource.local) {
record(docChange.change, docChange.before); record(docChange.change, docChange.before);
} else { } else {
transform(docChange.change); transform(docChange.change);
@ -105,7 +105,7 @@ class History {
dest.add(inverseDelta); dest.add(inverseDelta);
lastRecorded = 0; lastRecorded = 0;
ignoreChange = true; ignoreChange = true;
doc.compose(delta, ChangeSource.LOCAL); doc.compose(delta, ChangeSource.local);
ignoreChange = false; ignoreChange = false;
return HistoryChanged(true, len); return HistoryChanged(true, len);
} }

@ -137,17 +137,17 @@ abstract base class Container<T extends Node?> extends Node {
} }
@override @override
void retain(int index, int? length, Style? attributes) { void retain(int index, int? len, Style? style) {
assert(isNotEmpty); assert(isNotEmpty);
final child = queryChild(index, false); final child = queryChild(index, false);
child.node!.retain(child.offset, length, attributes); child.node!.retain(child.offset, len, style);
} }
@override @override
void delete(int index, int? length) { void delete(int index, int? len) {
assert(isNotEmpty); assert(isNotEmpty);
final child = queryChild(index, false); final child = queryChild(index, false);
child.node!.delete(child.offset, length); child.node!.delete(child.offset, len);
} }
@override @override

@ -30,7 +30,7 @@ class Embeddable {
/// the document model itself does not make any assumptions about the types /// the document model itself does not make any assumptions about the types
/// of embedded objects and allows users to define their own types. /// of embedded objects and allows users to define their own types.
class BlockEmbed extends Embeddable { class BlockEmbed extends Embeddable {
const BlockEmbed(String type, String data) : super(type, data); const BlockEmbed(super.type, String super.data);
static const String imageType = 'image'; static const String imageType = 'image';
static BlockEmbed image(String imageUrl) => BlockEmbed(imageType, imageUrl); static BlockEmbed image(String imageUrl) => BlockEmbed(imageType, imageUrl);
@ -47,7 +47,7 @@ class BlockEmbed extends Embeddable {
} }
class CustomBlockEmbed extends BlockEmbed { class CustomBlockEmbed extends BlockEmbed {
const CustomBlockEmbed(String type, String data) : super(type, data); const CustomBlockEmbed(super.type, super.data);
String toJsonString() => jsonEncode(toJson()); String toJsonString() => jsonEncode(toJson());

@ -217,9 +217,9 @@ abstract base class Leaf extends Node {
/// conflict with the one from the widgets, material or cupertino library /// conflict with the one from the widgets, material or cupertino library
/// ///
base class QuillText extends Leaf { base class QuillText extends Leaf {
QuillText([String text = '']) QuillText([String super.text = ''])
: assert(!text.contains('\n')), : assert(!text.contains('\n')),
super.val(text); super.val();
@override @override
Node newInstance() => QuillText(value); Node newInstance() => QuillText(value);
@ -250,7 +250,7 @@ base class QuillText extends Leaf {
/// applying "bold" style to an image gives no effect, while adding a "link" to /// applying "bold" style to an image gives no effect, while adding a "link" to
/// an image actually makes the image react to user's action. /// an image actually makes the image react to user's action.
base class Embed extends Leaf { base class Embed extends Leaf {
Embed(Embeddable data) : super.val(data); Embed(Embeddable super.data) : super.val();
// Refer to https://www.fileformat.info/info/unicode/char/fffc/index.htm // Refer to https://www.fileformat.info/info/unicode/char/fffc/index.htm
static const kObjectReplacementCharacter = '\uFFFC'; static const kObjectReplacementCharacter = '\uFFFC';

@ -136,15 +136,15 @@ base class Line extends Container<Leaf?> {
if (isLineFormat) { if (isLineFormat) {
assert( assert(
style.values.every((attr) => style.values.every((attr) =>
attr.scope == AttributeScope.BLOCK || attr.scope == AttributeScope.block ||
attr.scope == AttributeScope.IGNORE), attr.scope == AttributeScope.ignore),
'It is not allowed to apply inline attributes to line itself.'); 'It is not allowed to apply inline attributes to line itself.');
_format(style); _format(style);
} else { } else {
// Otherwise forward to children as it's an inline format update. // Otherwise forward to children as it's an inline format update.
assert(style.values.every((attr) => assert(style.values.every((attr) =>
attr.scope == AttributeScope.INLINE || attr.scope == AttributeScope.inline ||
attr.scope == AttributeScope.IGNORE)); attr.scope == AttributeScope.ignore));
assert(index + local != thisLength); assert(index + local != thisLength);
super.retain(index, local, style); super.retain(index, local, style);
} }
@ -351,7 +351,7 @@ base class Line extends Container<Leaf?> {
var result = const Style(); var result = const Style();
final excluded = <Attribute>{}; final excluded = <Attribute>{};
void _handle(Style style) { void handle(Style style) {
for (final attr in result.values) { for (final attr in result.values) {
if (!style.containsKey(attr.key) || if (!style.containsKey(attr.key) ||
(style.attributes[attr.key] != attr.value)) { (style.attributes[attr.key] != attr.value)) {
@ -368,7 +368,7 @@ base class Line extends Container<Leaf?> {
var pos = node.length - data.offset; var pos = node.length - data.offset;
while (!node!.isLast && pos < local) { while (!node!.isLast && pos < local) {
node = node.next as Leaf; node = node.next as Leaf;
_handle(node.style); handle(node.style);
pos += node.length; pos += node.length;
} }
} }
@ -382,7 +382,7 @@ base class Line extends Container<Leaf?> {
final remaining = len - local; final remaining = len - local;
if (remaining > 0 && nextLine != null) { if (remaining > 0 && nextLine != null) {
final rest = nextLine!.collectStyle(0, remaining); final rest = nextLine!.collectStyle(0, remaining);
_handle(rest); handle(rest);
} }
return result; return result;
@ -521,35 +521,35 @@ base class Line extends Container<Leaf?> {
} }
int _getPlainText(int offset, int len, StringBuffer plainText) { int _getPlainText(int offset, int len, StringBuffer plainText) {
var _len = len; var len0 = len;
final data = queryChild(offset, false); final data = queryChild(offset, false);
var node = data.node as Leaf?; var node = data.node as Leaf?;
while (_len > 0) { while (len0 > 0) {
if (node == null) { if (node == null) {
// blank line // blank line
plainText.write('\n'); plainText.write('\n');
_len -= 1; len0 -= 1;
} else { } else {
_len = _getNodeText(node, plainText, offset - node.offset, _len); len0 = _getNodeText(node, plainText, offset - node.offset, len0);
while (!node!.isLast && _len > 0) { while (!node!.isLast && len0 > 0) {
node = node.next as Leaf; node = node.next as Leaf;
_len = _getNodeText(node, plainText, 0, _len); len0 = _getNodeText(node, plainText, 0, len0);
} }
if (_len > 0) { if (len0 > 0) {
// end of this line // end of this line
plainText.write('\n'); plainText.write('\n');
_len -= 1; len0 -= 1;
} }
} }
if (_len > 0 && nextLine != null) { if (len0 > 0 && nextLine != null) {
_len = nextLine!._getPlainText(0, _len, plainText); len0 = nextLine!._getPlainText(0, len0, plainText);
} }
} }
return _len; return len0;
} }
} }

@ -21,7 +21,7 @@ class Style {
final result = attributes.map((key, dynamic value) { final result = attributes.map((key, dynamic value) {
final attr = Attribute.fromKeyValue(key, value); final attr = Attribute.fromKeyValue(key, value);
return MapEntry<String, Attribute>( return MapEntry<String, Attribute>(
key, attr ?? Attribute(key, AttributeScope.IGNORE, value)); key, attr ?? Attribute(key, AttributeScope.ignore, value));
}); });
return Style.attr(result); return Style.attr(result);
} }
@ -45,10 +45,10 @@ class Style {
bool get isInline => isNotEmpty && values.every((item) => item.isInline); bool get isInline => isNotEmpty && values.every((item) => item.isInline);
bool get isBlock => bool get isBlock =>
isNotEmpty && values.every((item) => item.scope == AttributeScope.BLOCK); isNotEmpty && values.every((item) => item.scope == AttributeScope.block);
bool get isIgnored => bool get isIgnored =>
isNotEmpty && values.every((item) => item.scope == AttributeScope.IGNORE); isNotEmpty && values.every((item) => item.scope == AttributeScope.ignore);
Attribute get single => _attributes.values.single; Attribute get single => _attributes.values.single;

@ -1,4 +1,6 @@
/// Implementation of Quill Delta format in Dart. /// Implementation of Quill Delta format in Dart.
library;
import 'dart:math' as math; import 'dart:math' as math;
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
@ -262,11 +264,11 @@ class Delta {
b ??= const {}; b ??= const {};
final attributes = <String, dynamic>{}; final attributes = <String, dynamic>{};
(a.keys.toList()..addAll(b.keys)).forEach((key) { for (final key in (a.keys.toList()..addAll(b.keys))) {
if (a![key] != b![key]) { if (a[key] != b[key]) {
attributes[key] = b.containsKey(key) ? b[key] : null; attributes[key] = b.containsKey(key) ? b[key] : null;
} }
}); }
return attributes.keys.isNotEmpty ? attributes : null; return attributes.keys.isNotEmpty ? attributes : null;
} }
@ -514,7 +516,7 @@ class Delta {
final thisIter = DeltaIterator(this); final thisIter = DeltaIterator(this);
final otherIter = DeltaIterator(other); final otherIter = DeltaIterator(other);
diffResult.forEach((component) { for (final component in diffResult) {
var length = component.text.length; var length = component.text.length;
while (length > 0) { while (length > 0) {
var opLength = 0; var opLength = 0;
@ -549,7 +551,7 @@ class Delta {
} }
length -= opLength; length -= opLength;
} }
}); }
return retDelta..trim(); return retDelta..trim();
} }
@ -787,9 +789,9 @@ class DeltaIterator {
final op = delta.elementAt(_index); final op = delta.elementAt(_index);
final opKey = op.key; final opKey = op.key;
final opAttributes = op.attributes; final opAttributes = op.attributes;
final _currentOffset = _offset; final currentOffset = _offset;
final actualLength = math.min(op.length! - _currentOffset, length); final actualLength = math.min(op.length! - currentOffset, length);
if (actualLength == op.length! - _currentOffset) { if (actualLength == op.length! - currentOffset) {
_index++; _index++;
_offset = 0; _offset = 0;
} else { } else {
@ -797,7 +799,7 @@ class DeltaIterator {
} }
final opData = op.isInsert && op.data is String final opData = op.isInsert && op.data is String
? (op.data as String) ? (op.data as String)
.substring(_currentOffset, _currentOffset + actualLength) .substring(currentOffset, currentOffset + actualLength)
: op.data; : op.data;
final opIsNotEmpty = final opIsNotEmpty =
opData is String ? opData.isNotEmpty : true; // embeds are never empty opData is String ? opData.isNotEmpty : true; // embeds are never empty

@ -8,7 +8,7 @@ abstract class DeleteRule extends Rule {
const DeleteRule(); const DeleteRule();
@override @override
RuleType get type => RuleType.DELETE; RuleType get type => RuleType.delete;
@override @override
void validateArgs(int? len, Object? data, Attribute? attribute) { void validateArgs(int? len, Object? data, Attribute? attribute) {

@ -7,7 +7,7 @@ abstract class FormatRule extends Rule {
const FormatRule(); const FormatRule();
@override @override
RuleType get type => RuleType.FORMAT; RuleType get type => RuleType.format;
@override @override
void validateArgs(int? len, Object? data, Attribute? attribute) { void validateArgs(int? len, Object? data, Attribute? attribute) {
@ -30,7 +30,7 @@ class ResolveLineFormatRule extends FormatRule {
Object? data, Object? data,
Attribute? attribute, Attribute? attribute,
}) { }) {
if (attribute!.scope != AttributeScope.BLOCK) { if (attribute!.scope != AttributeScope.block) {
return null; return null;
} }
@ -159,7 +159,7 @@ class ResolveInlineFormatRule extends FormatRule {
Object? data, Object? data,
Attribute? attribute, Attribute? attribute,
}) { }) {
if (attribute!.scope != AttributeScope.INLINE) { if (attribute!.scope != AttributeScope.inline) {
return null; return null;
} }

@ -10,7 +10,7 @@ abstract class InsertRule extends Rule {
const InsertRule(); const InsertRule();
@override @override
RuleType get type => RuleType.INSERT; RuleType get type => RuleType.insert;
@override @override
void validateArgs(int? len, Object? data, Attribute? attribute) { void validateArgs(int? len, Object? data, Attribute? attribute) {

@ -5,7 +5,7 @@ import 'delete.dart';
import 'format.dart'; import 'format.dart';
import 'insert.dart'; import 'insert.dart';
enum RuleType { INSERT, DELETE, FORMAT } enum RuleType { insert, delete, format }
abstract class Rule { abstract class Rule {
const Rule(); const Rule();

@ -7,7 +7,7 @@ import '../widgets/controller.dart';
OffsetValue<Embed> getEmbedNode(QuillController controller, int offset) { OffsetValue<Embed> getEmbedNode(QuillController controller, int offset) {
var offset = controller.selection.start; var offset = controller.selection.start;
var embedNode = controller.queryNode(offset); var embedNode = controller.queryNode(offset);
if (embedNode == null || !(embedNode is Embed)) { if (embedNode == null || embedNode is! Embed) {
offset = max(0, offset - 1); offset = max(0, offset - 1);
embedNode = controller.queryNode(offset); embedNode = controller.queryNode(offset);
} }

@ -6,13 +6,13 @@ Map<String, String> parseKeyValuePairs(String s, Set<String> targetKeys) {
final result = <String, String>{}; final result = <String, String>{};
final pairs = s.split(';'); final pairs = s.split(';');
for (final pair in pairs) { for (final pair in pairs) {
final _index = pair.indexOf(':'); final index = pair.indexOf(':');
if (_index < 0) { if (index < 0) {
continue; continue;
} }
final _key = pair.substring(0, _index).trim(); final key = pair.substring(0, index).trim();
if (targetKeys.contains(_key)) { if (targetKeys.contains(key)) {
result[_key] = pair.substring(_index + 1).trim(); result[key] = pair.substring(index + 1).trim();
} }
} }
@ -28,12 +28,12 @@ String replaceStyleStringWithSize(
final result = <String, String>{}; final result = <String, String>{};
final pairs = s.split(';'); final pairs = s.split(';');
for (final pair in pairs) { for (final pair in pairs) {
final _index = pair.indexOf(':'); final index = pair.indexOf(':');
if (_index < 0) { if (index < 0) {
continue; continue;
} }
final _key = pair.substring(0, _index).trim(); final key = pair.substring(0, index).trim();
result[_key] = pair.substring(_index + 1).trim(); result[key] = pair.substring(index + 1).trim();
} }
if (isMobile) { if (isMobile) {
@ -55,12 +55,12 @@ String replaceStyleStringWithSize(
} }
Alignment getAlignment(String? s) { Alignment getAlignment(String? s) {
const _defaultAlignment = Alignment.center; const defaultAlignment = Alignment.center;
if (s == null) { if (s == null) {
return _defaultAlignment; return defaultAlignment;
} }
final _index = [ final index = [
'topLeft', 'topLeft',
'topCenter', 'topCenter',
'topRight', 'topRight',
@ -71,8 +71,8 @@ Alignment getAlignment(String? s) {
'bottomCenter', 'bottomCenter',
'bottomRight' 'bottomRight'
].indexOf(s); ].indexOf(s);
if (_index < 0) { if (index < 0) {
return _defaultAlignment; return defaultAlignment;
} }
return [ return [
@ -85,5 +85,5 @@ Alignment getAlignment(String? s) {
Alignment.bottomLeft, Alignment.bottomLeft,
Alignment.bottomCenter, Alignment.bottomCenter,
Alignment.bottomRight Alignment.bottomRight
][_index]; ][index];
} }

@ -202,7 +202,7 @@ class QuillController extends ChangeNotifier {
// TextSelection.collapsed(offset: document.length), ChangeSource.LOCAL); // TextSelection.collapsed(offset: document.length), ChangeSource.LOCAL);
updateSelection( updateSelection(
TextSelection.collapsed(offset: selection.baseOffset + len), TextSelection.collapsed(offset: selection.baseOffset + len),
ChangeSource.LOCAL); ChangeSource.local);
} else { } else {
// no need to move cursor // no need to move cursor
notifyListeners(); notifyListeners();
@ -261,13 +261,13 @@ class QuillController extends ChangeNotifier {
final retainDelta = Delta() final retainDelta = Delta()
..retain(index) ..retain(index)
..retain(data is String ? data.length : 1, toggledStyle.toJson()); ..retain(data is String ? data.length : 1, toggledStyle.toJson());
document.compose(retainDelta, ChangeSource.LOCAL); document.compose(retainDelta, ChangeSource.local);
} }
} }
if (textSelection != null) { if (textSelection != null) {
if (delta == null || delta.isEmpty) { if (delta == null || delta.isEmpty) {
_updateSelection(textSelection, ChangeSource.LOCAL); _updateSelection(textSelection, ChangeSource.local);
} else { } else {
final user = Delta() final user = Delta()
..retain(index) ..retain(index)
@ -279,7 +279,7 @@ class QuillController extends ChangeNotifier {
baseOffset: textSelection.baseOffset + positionDelta, baseOffset: textSelection.baseOffset + positionDelta,
extentOffset: textSelection.extentOffset + positionDelta, extentOffset: textSelection.extentOffset + positionDelta,
), ),
ChangeSource.LOCAL, ChangeSource.local,
); );
} }
} }
@ -322,7 +322,7 @@ class QuillController extends ChangeNotifier {
baseOffset: change.transformPosition(selection.baseOffset), baseOffset: change.transformPosition(selection.baseOffset),
extentOffset: change.transformPosition(selection.extentOffset)); extentOffset: change.transformPosition(selection.extentOffset));
if (selection != adjustedSelection) { if (selection != adjustedSelection) {
_updateSelection(adjustedSelection, ChangeSource.LOCAL); _updateSelection(adjustedSelection, ChangeSource.local);
} }
notifyListeners(); notifyListeners();
} }
@ -334,21 +334,21 @@ class QuillController extends ChangeNotifier {
void moveCursorToStart() { void moveCursorToStart() {
updateSelection( updateSelection(
const TextSelection.collapsed(offset: 0), const TextSelection.collapsed(offset: 0),
ChangeSource.LOCAL, ChangeSource.local,
); );
} }
void moveCursorToPosition(int position) { void moveCursorToPosition(int position) {
updateSelection( updateSelection(
TextSelection.collapsed(offset: position), TextSelection.collapsed(offset: position),
ChangeSource.LOCAL, ChangeSource.local,
); );
} }
void moveCursorToEnd() { void moveCursorToEnd() {
updateSelection( updateSelection(
TextSelection.collapsed(offset: plainTextEditingValue.text.length), TextSelection.collapsed(offset: plainTextEditingValue.text.length),
ChangeSource.LOCAL, ChangeSource.local,
); );
} }

@ -11,9 +11,9 @@ import 'style_widgets/checkbox_point.dart';
class QuillStyles extends InheritedWidget { class QuillStyles extends InheritedWidget {
const QuillStyles({ const QuillStyles({
required this.data, required this.data,
required Widget child, required super.child,
Key? key, super.key,
}) : super(key: key, child: child); });
final DefaultStyles data; final DefaultStyles data;
@ -128,12 +128,12 @@ class InlineCodeStyle {
@immutable @immutable
class DefaultListBlockStyle extends DefaultTextBlockStyle { class DefaultListBlockStyle extends DefaultTextBlockStyle {
const DefaultListBlockStyle( const DefaultListBlockStyle(
TextStyle style, super.style,
VerticalSpacing verticalSpacing, super.verticalSpacing,
VerticalSpacing lineSpacing, super.lineSpacing,
BoxDecoration? decoration, super.decoration,
this.checkboxUIBuilder, this.checkboxUIBuilder,
) : super(style, verticalSpacing, lineSpacing, decoration); );
final QuillCheckboxBuilder? checkboxUIBuilder; final QuillCheckboxBuilder? checkboxUIBuilder;
} }

@ -402,8 +402,8 @@ class _QuillEditorSelectionGestureDetectorBuilder
return; return;
} }
final _platform = Theme.of(_state.context).platform; final platform = Theme.of(_state.context).platform;
if (isAppleOS(_platform)) { if (isAppleOS(platform)) {
renderEditor!.selectPositionAt( renderEditor!.selectPositionAt(
from: details.globalPosition, from: details.globalPosition,
cause: SelectionChangedCause.longPress, cause: SelectionChangedCause.longPress,
@ -432,7 +432,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
if (segmentLeaf == null && line.length == 1) { if (segmentLeaf == null && line.length == 1) {
editor!.widget.controller.updateSelection( editor!.widget.controller.updateSelection(
TextSelection.collapsed(offset: pos.offset), TextSelection.collapsed(offset: pos.offset),
ChangeSource.LOCAL, ChangeSource.local,
); );
return true; return true;
} }
@ -475,8 +475,8 @@ class _QuillEditorSelectionGestureDetectorBuilder
try { try {
if (delegate.selectionEnabled && !_isPositionSelected(details)) { if (delegate.selectionEnabled && !_isPositionSelected(details)) {
final _platform = Theme.of(_state.context).platform; final platform = Theme.of(_state.context).platform;
if (isAppleOS(_platform) || isDesktop()) { if (isAppleOS(platform) || isDesktop()) {
// added isDesktop() to enable extend selection in Windows platform // added isDesktop() to enable extend selection in Windows platform
switch (details.kind) { switch (details.kind) {
case PointerDeviceKind.mouse: case PointerDeviceKind.mouse:
@ -539,8 +539,8 @@ class _QuillEditorSelectionGestureDetectorBuilder
} }
if (delegate.selectionEnabled) { if (delegate.selectionEnabled) {
final _platform = Theme.of(_state.context).platform; final platform = Theme.of(_state.context).platform;
if (isAppleOS(_platform)) { if (isAppleOS(platform)) {
renderEditor!.selectPositionAt( renderEditor!.selectPositionAt(
from: details.globalPosition, from: details.globalPosition,
cause: SelectionChangedCause.longPress, cause: SelectionChangedCause.longPress,
@ -608,20 +608,20 @@ class RenderEditor extends RenderEditableContainerBox
implements RenderAbstractEditor { implements RenderAbstractEditor {
RenderEditor({ RenderEditor({
required this.document, required this.document,
required TextDirection textDirection, required super.textDirection,
required bool hasFocus, required bool hasFocus,
required this.selection, required this.selection,
required this.scrollable, required this.scrollable,
required LayerLink startHandleLayerLink, required LayerLink startHandleLayerLink,
required LayerLink endHandleLayerLink, required LayerLink endHandleLayerLink,
required EdgeInsetsGeometry padding, required super.padding,
required CursorCont cursorController, required CursorCont cursorController,
required this.onSelectionChanged, required this.onSelectionChanged,
required this.onSelectionCompleted, required this.onSelectionCompleted,
required double scrollBottomInset, required super.scrollBottomInset,
required this.floatingCursorDisabled, required this.floatingCursorDisabled,
ViewportOffset? offset, ViewportOffset? offset,
List<RenderEditableBox>? children, super.children,
EdgeInsets floatingCursorAddedMargin = EdgeInsets floatingCursorAddedMargin =
const EdgeInsets.fromLTRB(4, 4, 4, 5), const EdgeInsets.fromLTRB(4, 4, 4, 5),
double? maxContentWidth, double? maxContentWidth,
@ -632,11 +632,7 @@ class RenderEditor extends RenderEditableContainerBox
_cursorController = cursorController, _cursorController = cursorController,
_maxContentWidth = maxContentWidth, _maxContentWidth = maxContentWidth,
super( super(
children: children,
container: document.root, container: document.root,
textDirection: textDirection,
scrollBottomInset: scrollBottomInset,
padding: padding,
); );
final CursorCont _cursorController; final CursorCont _cursorController;

@ -31,8 +31,7 @@ class QuillPressedKeys extends ChangeNotifier {
} }
class QuillKeyboardListener extends StatefulWidget { class QuillKeyboardListener extends StatefulWidget {
const QuillKeyboardListener({required this.child, Key? key}) const QuillKeyboardListener({required this.child, super.key});
: super(key: key);
final Widget child; final Widget child;
@ -77,9 +76,8 @@ class QuillKeyboardListenerState extends State<QuillKeyboardListener> {
class _QuillPressedKeysAccess extends InheritedWidget { class _QuillPressedKeysAccess extends InheritedWidget {
const _QuillPressedKeysAccess({ const _QuillPressedKeysAccess({
required this.pressedKeys, required this.pressedKeys,
required Widget child, required super.child,
Key? key, });
}) : super(key: key, child: child);
final QuillPressedKeys pressedKeys; final QuillPressedKeys pressedKeys;

@ -124,8 +124,7 @@ class _CupertinoAction extends StatelessWidget {
required this.title, required this.title,
required this.icon, required this.icon,
required this.onPressed, required this.onPressed,
Key? key, });
}) : super(key: key);
final String title; final String title;
final IconData icon; final IconData icon;
@ -195,8 +194,7 @@ class _MaterialAction extends StatelessWidget {
required this.title, required this.title,
required this.icon, required this.icon,
required this.onPressed, required this.onPressed,
Key? key, });
}) : super(key: key);
final String title; final String title;
final IconData icon; final IconData icon;

@ -7,11 +7,11 @@ import 'box.dart';
class BaselineProxy extends SingleChildRenderObjectWidget { class BaselineProxy extends SingleChildRenderObjectWidget {
const BaselineProxy({ const BaselineProxy({
Key? key, super.key,
Widget? child, super.child,
this.textStyle, this.textStyle,
this.padding, this.padding,
}) : super(key: key, child: child); });
final TextStyle? textStyle; final TextStyle? textStyle;
final EdgeInsets? padding; final EdgeInsets? padding;
@ -36,15 +36,14 @@ class BaselineProxy extends SingleChildRenderObjectWidget {
class RenderBaselineProxy extends RenderProxyBox { class RenderBaselineProxy extends RenderProxyBox {
RenderBaselineProxy( RenderBaselineProxy(
RenderParagraph? child, RenderParagraph? super.child,
TextStyle textStyle, TextStyle textStyle,
EdgeInsets? padding, EdgeInsets? padding,
) : _prototypePainter = TextPainter( ) : _prototypePainter = TextPainter(
text: TextSpan(text: ' ', style: textStyle), text: TextSpan(text: ' ', style: textStyle),
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
strutStyle: strutStyle:
StrutStyle.fromTextStyle(textStyle, forceStrutHeight: true)), StrutStyle.fromTextStyle(textStyle, forceStrutHeight: true));
super(child);
final TextPainter _prototypePainter; final TextPainter _prototypePainter;
@ -87,7 +86,7 @@ class EmbedProxy extends SingleChildRenderObjectWidget {
} }
class RenderEmbedProxy extends RenderProxyBox implements RenderContentProxyBox { class RenderEmbedProxy extends RenderProxyBox implements RenderContentProxyBox {
RenderEmbedProxy(RenderBox? child) : super(child); RenderEmbedProxy(super.child);
@override @override
List<TextBox> getBoxesForSelection(TextSelection selection) { List<TextBox> getBoxesForSelection(TextSelection selection) {
@ -131,7 +130,7 @@ class RenderEmbedProxy extends RenderProxyBox implements RenderContentProxyBox {
class RichTextProxy extends SingleChildRenderObjectWidget { class RichTextProxy extends SingleChildRenderObjectWidget {
/// Child argument should be an instance of RichText widget. /// Child argument should be an instance of RichText widget.
const RichTextProxy( const RichTextProxy(
{required RichText child, {required RichText super.child,
required this.textStyle, required this.textStyle,
required this.textAlign, required this.textAlign,
required this.textDirection, required this.textDirection,
@ -140,8 +139,7 @@ class RichTextProxy extends SingleChildRenderObjectWidget {
this.textScaleFactor = 1.0, this.textScaleFactor = 1.0,
this.textWidthBasis = TextWidthBasis.parent, this.textWidthBasis = TextWidthBasis.parent,
this.textHeightBehavior, this.textHeightBehavior,
Key? key}) super.key});
: super(key: key, child: child);
final TextStyle textStyle; final TextStyle textStyle;
final TextAlign textAlign; final TextAlign textAlign;
@ -184,7 +182,7 @@ class RichTextProxy extends SingleChildRenderObjectWidget {
class RenderParagraphProxy extends RenderProxyBox class RenderParagraphProxy extends RenderProxyBox
implements RenderContentProxyBox { implements RenderContentProxyBox {
RenderParagraphProxy( RenderParagraphProxy(
RenderParagraph? child, RenderParagraph? super.child,
TextStyle textStyle, TextStyle textStyle,
TextAlign textAlign, TextAlign textAlign,
TextDirection textDirection, TextDirection textDirection,
@ -193,7 +191,7 @@ class RenderParagraphProxy extends RenderProxyBox
Locale locale, Locale locale,
TextWidthBasis textWidthBasis, TextWidthBasis textWidthBasis,
TextHeightBehavior? textHeightBehavior, TextHeightBehavior? textHeightBehavior,
) : _prototypePainter = TextPainter( ) : _prototypePainter = TextPainter(
text: TextSpan(text: ' ', style: textStyle), text: TextSpan(text: ' ', style: textStyle),
textAlign: textAlign, textAlign: textAlign,
textDirection: textDirection, textDirection: textDirection,
@ -201,8 +199,7 @@ class RenderParagraphProxy extends RenderProxyBox
strutStyle: strutStyle, strutStyle: strutStyle,
locale: locale, locale: locale,
textWidthBasis: textWidthBasis, textWidthBasis: textWidthBasis,
textHeightBehavior: textHeightBehavior), textHeightBehavior: textHeightBehavior);
super(child);
final TextPainter _prototypePainter; final TextPainter _prototypePainter;

@ -77,9 +77,8 @@ class QuillSingleChildScrollView extends StatelessWidget {
class _SingleChildViewport extends SingleChildRenderObjectWidget { class _SingleChildViewport extends SingleChildRenderObjectWidget {
const _SingleChildViewport({ const _SingleChildViewport({
required this.offset, required this.offset,
Key? key, super.child,
Widget? child, });
}) : super(key: key, child: child);
final ViewportOffset offset; final ViewportOffset offset;

@ -468,10 +468,10 @@ class RawEditorState extends EditorState
assert(debugCheckHasMediaQuery(context)); assert(debugCheckHasMediaQuery(context));
super.build(context); super.build(context);
var _doc = controller.document; var doc = controller.document;
if (_doc.isEmpty() && widget.placeholder != null) { if (doc.isEmpty() && widget.placeholder != null) {
final raw = widget.placeholder?.replaceAll(r'"', '\\"'); final raw = widget.placeholder?.replaceAll(r'"', '\\"');
_doc = Document.fromJson( doc = Document.fromJson(
jsonDecode( jsonDecode(
'[{"attributes":{"placeholder":true},"insert":"$raw\\n"}]', '[{"attributes":{"placeholder":true},"insert":"$raw\\n"}]',
), ),
@ -485,7 +485,7 @@ class RawEditorState extends EditorState
cursor: SystemMouseCursors.text, cursor: SystemMouseCursors.text,
child: _Editor( child: _Editor(
key: _editorKey, key: _editorKey,
document: _doc, document: doc,
selection: controller.selection, selection: controller.selection,
hasFocus: _hasFocus, hasFocus: _hasFocus,
scrollable: widget.scrollable, scrollable: widget.scrollable,
@ -499,7 +499,7 @@ class RawEditorState extends EditorState
padding: widget.padding, padding: widget.padding,
maxContentWidth: widget.maxContentWidth, maxContentWidth: widget.maxContentWidth,
floatingCursorDisabled: widget.floatingCursorDisabled, floatingCursorDisabled: widget.floatingCursorDisabled,
children: _buildChildren(_doc, context), children: _buildChildren(doc, context),
), ),
), ),
), ),
@ -527,7 +527,7 @@ class RawEditorState extends EditorState
child: _Editor( child: _Editor(
key: _editorKey, key: _editorKey,
offset: offset, offset: offset,
document: _doc, document: doc,
selection: controller.selection, selection: controller.selection,
hasFocus: _hasFocus, hasFocus: _hasFocus,
scrollable: widget.scrollable, scrollable: widget.scrollable,
@ -541,7 +541,7 @@ class RawEditorState extends EditorState
maxContentWidth: widget.maxContentWidth, maxContentWidth: widget.maxContentWidth,
cursorController: _cursorCont, cursorController: _cursorCont,
floatingCursorDisabled: widget.floatingCursorDisabled, floatingCursorDisabled: widget.floatingCursorDisabled,
children: _buildChildren(_doc, context), children: _buildChildren(doc, context),
), ),
), ),
), ),
@ -853,7 +853,7 @@ class RawEditorState extends EditorState
controller.selection.copyWith( controller.selection.copyWith(
baseOffset: selection.baseOffset + chars, baseOffset: selection.baseOffset + chars,
extentOffset: selection.baseOffset + chars), extentOffset: selection.baseOffset + chars),
ChangeSource.LOCAL); ChangeSource.local);
} }
void _updateSelectionForKeyPhrase(String phrase, Attribute attribute) { void _updateSelectionForKeyPhrase(String phrase, Attribute attribute) {
@ -871,7 +871,7 @@ class RawEditorState extends EditorState
SelectionChangedCause cause, SelectionChangedCause cause,
) { ) {
final oldSelection = controller.selection; final oldSelection = controller.selection;
controller.updateSelection(selection, ChangeSource.LOCAL); controller.updateSelection(selection, ChangeSource.local);
_selectionOverlay?.handlesVisible = _shouldShowSelectionHandles(); _selectionOverlay?.handlesVisible = _shouldShowSelectionHandles();
@ -925,7 +925,7 @@ class RawEditorState extends EditorState
controller controller
..ignoreFocusOnTextChange = false ..ignoreFocusOnTextChange = false
..skipRequestKeyboard = !requestKeyboardFocusOnCheckListChanged ..skipRequestKeyboard = !requestKeyboardFocusOnCheckListChanged
..updateSelection(currentSelection, ChangeSource.LOCAL); ..updateSelection(currentSelection, ChangeSource.local);
}); });
} }
} }
@ -1839,8 +1839,8 @@ class RawEditorState extends EditorState
class _Editor extends MultiChildRenderObjectWidget { class _Editor extends MultiChildRenderObjectWidget {
const _Editor({ const _Editor({
required Key key, required Key super.key,
required List<Widget> children, required super.children,
required this.document, required this.document,
required this.textDirection, required this.textDirection,
required this.hasFocus, required this.hasFocus,
@ -1856,7 +1856,7 @@ class _Editor extends MultiChildRenderObjectWidget {
this.padding = EdgeInsets.zero, this.padding = EdgeInsets.zero,
this.maxContentWidth, this.maxContentWidth,
this.offset, this.offset,
}) : super(key: key, children: children); });
final ViewportOffset? offset; final ViewportOffset? offset;
final Document document; final Document document;
@ -2292,7 +2292,7 @@ class _UpdateTextSelectionAction<T extends DirectionalCaretMovementIntent>
final collapseSelection = final collapseSelection =
intent.collapseSelection || !state.widget.selectionEnabled; intent.collapseSelection || !state.widget.selectionEnabled;
// Collapse to the logical start/end. // Collapse to the logical start/end.
TextSelection _collapse(TextSelection selection) { TextSelection collapse(TextSelection selection) {
assert(selection.isValid); assert(selection.isValid);
assert(!selection.isCollapsed); assert(!selection.isCollapsed);
return selection.copyWith( return selection.copyWith(
@ -2306,7 +2306,7 @@ class _UpdateTextSelectionAction<T extends DirectionalCaretMovementIntent>
collapseSelection) { collapseSelection) {
return Actions.invoke( return Actions.invoke(
context!, context!,
UpdateSelectionIntent(state.textEditingValue, _collapse(selection), UpdateSelectionIntent(state.textEditingValue, collapse(selection),
SelectionChangedCause.keyboard), SelectionChangedCause.keyboard),
); );
} }
@ -2322,7 +2322,7 @@ class _UpdateTextSelectionAction<T extends DirectionalCaretMovementIntent>
return Actions.invoke( return Actions.invoke(
context!, context!,
UpdateSelectionIntent(state.textEditingValue, UpdateSelectionIntent(state.textEditingValue,
_collapse(textBoundarySelection), SelectionChangedCause.keyboard), collapse(textBoundarySelection), SelectionChangedCause.keyboard),
); );
} }
@ -2682,9 +2682,9 @@ class _ApplyHeaderAction extends Action<ApplyHeaderIntent> {
@override @override
void invoke(ApplyHeaderIntent intent, [BuildContext? context]) { void invoke(ApplyHeaderIntent intent, [BuildContext? context]) {
final _attribute = final attribute =
_getHeaderValue() == intent.header ? Attribute.header : intent.header; _getHeaderValue() == intent.header ? Attribute.header : intent.header;
state.controller.formatSelection(_attribute); state.controller.formatSelection(attribute);
} }
@override @override

@ -24,7 +24,7 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState
final diff = getDiff(oldText, newText, cursorPosition); final diff = getDiff(oldText, newText, cursorPosition);
if (diff.deleted == '' && diff.inserted == '') { if (diff.deleted == '' && diff.inserted == '') {
// Only changing selection range // Only changing selection range
widget.controller.updateSelection(value.selection, ChangeSource.LOCAL); widget.controller.updateSelection(value.selection, ChangeSource.local);
return; return;
} }
@ -61,9 +61,9 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState
final node = widget.controller.document.queryChild(local).node; final node = widget.controller.document.queryChild(local).node;
if (node != null && if (node != null &&
pasteStyleAndEmbed[i].length == node.length - 1) { pasteStyleAndEmbed[i].length == node.length - 1) {
style.values.forEach((attribute) { for (final attribute in style.values) {
widget.controller.document.format(local, 0, attribute); widget.controller.document.format(local, 0, attribute);
}); }
} }
} }
} }

@ -187,7 +187,7 @@ mixin RawEditorStateTextInputClientMixin on EditorState
final cursorPosition = value.selection.extentOffset; final cursorPosition = value.selection.extentOffset;
final diff = getDiff(oldText, text, cursorPosition); final diff = getDiff(oldText, text, cursorPosition);
if (diff.deleted.isEmpty && diff.inserted.isEmpty) { if (diff.deleted.isEmpty && diff.inserted.isEmpty) {
widget.controller.updateSelection(value.selection, ChangeSource.LOCAL); widget.controller.updateSelection(value.selection, ChangeSource.local);
} else { } else {
widget.controller.replaceText( widget.controller.replaceText(
diff.start, diff.deleted.length, diff.inserted, value.selection); diff.start, diff.deleted.length, diff.inserted, value.selection);

@ -5,8 +5,8 @@ class QuillEditorBulletPoint extends StatelessWidget {
required this.style, required this.style,
required this.width, required this.width,
this.padding = 0, this.padding = 0,
Key? key, super.key,
}) : super(key: key); });
final TextStyle style; final TextStyle style;
final double width; final double width;

@ -20,11 +20,11 @@ class QuillEditorCheckboxPoint extends StatefulWidget {
final QuillCheckboxBuilder? uiBuilder; final QuillCheckboxBuilder? uiBuilder;
@override @override
_QuillEditorCheckboxPointState createState() => QuillEditorCheckboxPointState createState() =>
_QuillEditorCheckboxPointState(); QuillEditorCheckboxPointState();
} }
class _QuillEditorCheckboxPointState extends State<QuillEditorCheckboxPoint> { class QuillEditorCheckboxPointState extends State<QuillEditorCheckboxPoint> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final uiBuilder = widget.uiBuilder; final uiBuilder = widget.uiBuilder;

@ -351,21 +351,18 @@ class RenderEditableTextBlock extends RenderEditableContainerBox
implements RenderEditableBox { implements RenderEditableBox {
RenderEditableTextBlock({ RenderEditableTextBlock({
required Block block, required Block block,
required TextDirection textDirection, required super.textDirection,
required EdgeInsetsGeometry padding, required EdgeInsetsGeometry padding,
required double scrollBottomInset, required super.scrollBottomInset,
required Decoration decoration, required Decoration decoration,
List<RenderEditableBox>? children, super.children,
EdgeInsets contentPadding = EdgeInsets.zero, EdgeInsets contentPadding = EdgeInsets.zero,
}) : _decoration = decoration, }) : _decoration = decoration,
_configuration = ImageConfiguration(textDirection: textDirection), _configuration = ImageConfiguration(textDirection: textDirection),
_savedPadding = padding, _savedPadding = padding,
_contentPadding = contentPadding, _contentPadding = contentPadding,
super( super(
children: children,
container: block, container: block,
textDirection: textDirection,
scrollBottomInset: scrollBottomInset,
padding: padding.add(contentPadding), padding: padding.add(contentPadding),
); );
@ -665,9 +662,7 @@ class _EditableBlock extends MultiChildRenderObjectWidget {
required this.scrollBottomInset, required this.scrollBottomInset,
required this.decoration, required this.decoration,
required this.contentPadding, required this.contentPadding,
required List<Widget> children, required super.children});
Key? key})
: super(key: key, children: children);
final Block block; final Block block;
final TextDirection textDirection; final TextDirection textDirection;

@ -294,14 +294,14 @@ class _TextLineState extends State<TextLine> {
if (widget.customStyleBuilder == null) { if (widget.customStyleBuilder == null) {
return textStyle; return textStyle;
} }
attributes.keys.forEach((key) { for (final key in attributes.keys) {
final attr = attributes[key]; final attr = attributes[key];
if (attr != null) { if (attr != null) {
/// Custom Attribute /// Custom Attribute
final customAttr = widget.customStyleBuilder!.call(attr); final customAttr = widget.customStyleBuilder!.call(attr);
textStyle = textStyle.merge(customAttr); textStyle = textStyle.merge(customAttr);
} }
}); }
return textStyle; return textStyle;
} }
@ -1292,7 +1292,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
class _TextLineElement extends RenderObjectElement { class _TextLineElement extends RenderObjectElement {
_TextLineElement(EditableTextLine line) : super(line); _TextLineElement(EditableTextLine super.line);
final Map<TextLineSlot, Element> _slotToChildren = <TextLineSlot, Element>{}; final Map<TextLineSlot, Element> _slotToChildren = <TextLineSlot, Element>{};

@ -21,22 +21,17 @@ TextSelection localSelection(Node node, TextSelection selection, fromParent) {
/// The text position that a give selection handle manipulates. Dragging the /// The text position that a give selection handle manipulates. Dragging the
/// [start] handle always moves the [start]/[baseOffset] of the selection. /// [start] handle always moves the [start]/[baseOffset] of the selection.
enum _TextSelectionHandlePosition { START, END } enum _TextSelectionHandlePosition { start, end }
/// internal use, used to get drag direction information /// internal use, used to get drag direction information
class DragTextSelection extends TextSelection { class DragTextSelection extends TextSelection {
const DragTextSelection({ const DragTextSelection({
TextAffinity affinity = TextAffinity.downstream, super.affinity,
int baseOffset = 0, super.baseOffset = 0,
int extentOffset = 0, super.extentOffset = 0,
bool isDirectional = false, super.isDirectional,
this.first = true, this.first = true,
}) : super( });
baseOffset: baseOffset,
extentOffset: extentOffset,
affinity: affinity,
isDirectional: isDirectional,
);
final bool first; final bool first;
@ -236,7 +231,7 @@ class EditorTextSelectionOverlay {
Widget _buildHandle( Widget _buildHandle(
BuildContext context, _TextSelectionHandlePosition position) { BuildContext context, _TextSelectionHandlePosition position) {
if (_selection.isCollapsed && if (_selection.isCollapsed &&
position == _TextSelectionHandlePosition.END) { position == _TextSelectionHandlePosition.end) {
return Container(); return Container();
} }
return Visibility( return Visibility(
@ -282,12 +277,12 @@ class EditorTextSelectionOverlay {
TextSelection? newSelection, _TextSelectionHandlePosition position) { TextSelection? newSelection, _TextSelectionHandlePosition position) {
TextPosition textPosition; TextPosition textPosition;
switch (position) { switch (position) {
case _TextSelectionHandlePosition.START: case _TextSelectionHandlePosition.start:
textPosition = newSelection != null textPosition = newSelection != null
? newSelection.base ? newSelection.base
: const TextPosition(offset: 0); : const TextPosition(offset: 0);
break; break;
case _TextSelectionHandlePosition.END: case _TextSelectionHandlePosition.end:
textPosition = newSelection != null textPosition = newSelection != null
? newSelection.extent ? newSelection.extent
: const TextPosition(offset: 0); : const TextPosition(offset: 0);
@ -302,7 +297,7 @@ class EditorTextSelectionOverlay {
extentOffset: newSelection.extentOffset, extentOffset: newSelection.extentOffset,
affinity: newSelection.affinity, affinity: newSelection.affinity,
isDirectional: newSelection.isDirectional, isDirectional: newSelection.isDirectional,
first: position == _TextSelectionHandlePosition.START, first: position == _TextSelectionHandlePosition.start,
) )
: null; : null;
@ -344,10 +339,10 @@ class EditorTextSelectionOverlay {
_handles = <OverlayEntry>[ _handles = <OverlayEntry>[
OverlayEntry( OverlayEntry(
builder: (context) => builder: (context) =>
_buildHandle(context, _TextSelectionHandlePosition.START)), _buildHandle(context, _TextSelectionHandlePosition.start)),
OverlayEntry( OverlayEntry(
builder: (context) => builder: (context) =>
_buildHandle(context, _TextSelectionHandlePosition.END)), _buildHandle(context, _TextSelectionHandlePosition.end)),
]; ];
Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor) Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor)
@ -375,8 +370,7 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
required this.onSelectionHandleTapped, required this.onSelectionHandleTapped,
required this.selectionControls, required this.selectionControls,
this.dragStartBehavior = DragStartBehavior.start, this.dragStartBehavior = DragStartBehavior.start,
Key? key, });
}) : super(key: key);
final TextSelection selection; final TextSelection selection;
final _TextSelectionHandlePosition position; final _TextSelectionHandlePosition position;
@ -394,9 +388,9 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
ValueListenable<bool> get _visibility { ValueListenable<bool> get _visibility {
switch (position) { switch (position) {
case _TextSelectionHandlePosition.START: case _TextSelectionHandlePosition.start:
return renderObject.selectionStartInViewport; return renderObject.selectionStartInViewport;
case _TextSelectionHandlePosition.END: case _TextSelectionHandlePosition.end:
return renderObject.selectionEndInViewport; return renderObject.selectionEndInViewport;
default: default:
throw 'Invalid position'; throw 'Invalid position';
@ -449,7 +443,7 @@ class _TextSelectionHandleOverlayState
} }
void _handleDragStart(DragStartDetails details) { void _handleDragStart(DragStartDetails details) {
final textPosition = widget.position == _TextSelectionHandlePosition.START final textPosition = widget.position == _TextSelectionHandlePosition.start
? widget.selection.base ? widget.selection.base
: widget.selection.extent; : widget.selection.extent;
final lineHeight = widget.renderObject.preferredLineHeight(textPosition); final lineHeight = widget.renderObject.preferredLineHeight(textPosition);
@ -470,7 +464,7 @@ class _TextSelectionHandleOverlayState
widget.selection.extentOffset >= widget.selection.baseOffset; widget.selection.extentOffset >= widget.selection.baseOffset;
TextSelection newSelection; TextSelection newSelection;
switch (widget.position) { switch (widget.position) {
case _TextSelectionHandlePosition.START: case _TextSelectionHandlePosition.start:
newSelection = TextSelection( newSelection = TextSelection(
baseOffset: baseOffset:
isNormalized ? position.offset : widget.selection.baseOffset, isNormalized ? position.offset : widget.selection.baseOffset,
@ -478,7 +472,7 @@ class _TextSelectionHandleOverlayState
isNormalized ? widget.selection.extentOffset : position.offset, isNormalized ? widget.selection.extentOffset : position.offset,
); );
break; break;
case _TextSelectionHandlePosition.END: case _TextSelectionHandlePosition.end:
newSelection = TextSelection( newSelection = TextSelection(
baseOffset: baseOffset:
isNormalized ? widget.selection.baseOffset : position.offset, isNormalized ? widget.selection.baseOffset : position.offset,
@ -507,7 +501,7 @@ class _TextSelectionHandleOverlayState
TextSelectionHandleType? type; TextSelectionHandleType? type;
switch (widget.position) { switch (widget.position) {
case _TextSelectionHandlePosition.START: case _TextSelectionHandlePosition.start:
layerLink = widget.startHandleLayerLink; layerLink = widget.startHandleLayerLink;
type = _chooseType( type = _chooseType(
widget.renderObject.textDirection, widget.renderObject.textDirection,
@ -515,7 +509,7 @@ class _TextSelectionHandleOverlayState
TextSelectionHandleType.right, TextSelectionHandleType.right,
); );
break; break;
case _TextSelectionHandlePosition.END: case _TextSelectionHandlePosition.end:
// For collapsed selections, we shouldn't be building the [end] handle. // For collapsed selections, we shouldn't be building the [end] handle.
assert(!widget.selection.isCollapsed); assert(!widget.selection.isCollapsed);
layerLink = widget.endHandleLayerLink; layerLink = widget.endHandleLayerLink;
@ -533,7 +527,7 @@ class _TextSelectionHandleOverlayState
// May have to use getSelectionBoxes instead of preferredLineHeight. // May have to use getSelectionBoxes instead of preferredLineHeight.
// or expose TextStyle on the render object and calculate // or expose TextStyle on the render object and calculate
// preferredLineHeight / style.height // preferredLineHeight / style.height
final textPosition = widget.position == _TextSelectionHandlePosition.START final textPosition = widget.position == _TextSelectionHandlePosition.start
? widget.selection.base ? widget.selection.base
: widget.selection.extent; : widget.selection.extent;
final lineHeight = widget.renderObject.preferredLineHeight(textPosition); final lineHeight = widget.renderObject.preferredLineHeight(textPosition);
@ -649,8 +643,8 @@ class EditorTextSelectionGestureDetector extends StatefulWidget {
this.onDragSelectionEnd, this.onDragSelectionEnd,
this.behavior, this.behavior,
this.detectWordBoundary = true, this.detectWordBoundary = true,
Key? key, super.key,
}) : super(key: key); });
/// Called for every tap down including every tap down that's part of a /// Called for every tap down including every tap down that's part of a
/// double click or a long press, except touches that include enough movement /// double click or a long press, except touches that include enough movement
@ -1001,8 +995,8 @@ class _EditorTextSelectionGestureDetectorState
// underlying input. // underlying input.
class _TransparentTapGestureRecognizer extends TapGestureRecognizer { class _TransparentTapGestureRecognizer extends TapGestureRecognizer {
_TransparentTapGestureRecognizer({ _TransparentTapGestureRecognizer({
Object? debugOwner, super.debugOwner,
}) : super(debugOwner: debugOwner); });
@override @override
void rejectGesture(int pointer) { void rejectGesture(int pointer) {

@ -17,11 +17,11 @@ class QuillToolbarArrowIndicatedButtonList extends StatefulWidget {
final List<Widget> buttons; final List<Widget> buttons;
@override @override
_QuillToolbarArrowIndicatedButtonListState createState() => QuillToolbarArrowIndicatedButtonListState createState() =>
_QuillToolbarArrowIndicatedButtonListState(); QuillToolbarArrowIndicatedButtonListState();
} }
class _QuillToolbarArrowIndicatedButtonListState class QuillToolbarArrowIndicatedButtonListState
extends State<QuillToolbarArrowIndicatedButtonList> extends State<QuillToolbarArrowIndicatedButtonList>
with WidgetsBindingObserver { with WidgetsBindingObserver {
final ScrollController _controller = ScrollController(); final ScrollController _controller = ScrollController();

@ -28,11 +28,10 @@ class QuillToolbarColorButton extends StatefulWidget {
final QuillToolbarColorButtonOptions options; final QuillToolbarColorButtonOptions options;
@override @override
_QuillToolbarColorButtonState createState() => QuillToolbarColorButtonState createState() => QuillToolbarColorButtonState();
_QuillToolbarColorButtonState();
} }
class _QuillToolbarColorButtonState extends State<QuillToolbarColorButton> { class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
late bool _isToggledColor; late bool _isToggledColor;
late bool _isToggledBackground; late bool _isToggledBackground;
late bool _isWhite; late bool _isWhite;

@ -26,11 +26,11 @@ class QuillToolbarFontFamilyButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
@override @override
_QuillToolbarFontFamilyButtonState createState() => QuillToolbarFontFamilyButtonState createState() =>
_QuillToolbarFontFamilyButtonState(); QuillToolbarFontFamilyButtonState();
} }
class _QuillToolbarFontFamilyButtonState class QuillToolbarFontFamilyButtonState
extends State<QuillToolbarFontFamilyButton> { extends State<QuillToolbarFontFamilyButton> {
var _currentValue = ''; var _currentValue = '';

@ -21,11 +21,11 @@ class QuillToolbarFontSizeButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
@override @override
_QuillToolbarFontSizeButtonState createState() => QuillToolbarFontSizeButtonState createState() =>
_QuillToolbarFontSizeButtonState(); QuillToolbarFontSizeButtonState();
} }
class _QuillToolbarFontSizeButtonState class QuillToolbarFontSizeButtonState
extends State<QuillToolbarFontSizeButton> { extends State<QuillToolbarFontSizeButton> {
String _currentValue = ''; String _currentValue = '';

@ -16,11 +16,11 @@ class QuillToolbarHistoryButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
@override @override
_QuillToolbarHistoryButtonState createState() => QuillToolbarHistoryButtonState createState() =>
_QuillToolbarHistoryButtonState(); QuillToolbarHistoryButtonState();
} }
class _QuillToolbarHistoryButtonState extends State<QuillToolbarHistoryButton> { class QuillToolbarHistoryButtonState extends State<QuillToolbarHistoryButton> {
late ThemeData theme; late ThemeData theme;
var _canPressed = false; var _canPressed = false;

@ -24,11 +24,11 @@ class QuillToolbarIndentButton extends StatefulWidget {
final QuillToolbarIndentButtonOptions options; final QuillToolbarIndentButtonOptions options;
@override @override
_QuillToolbarIndentButtonState createState() => QuillToolbarIndentButtonState createState() =>
_QuillToolbarIndentButtonState(); QuillToolbarIndentButtonState();
} }
class _QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> { class QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> {
QuillToolbarIndentButtonOptions get options { QuillToolbarIndentButtonOptions get options {
return widget.options; return widget.options;
} }

@ -22,11 +22,11 @@ class QuillToolbarLinkStyleButton extends StatefulWidget {
final QuillToolbarLinkStyleButtonOptions options; final QuillToolbarLinkStyleButtonOptions options;
@override @override
_QuillToolbarLinkStyleButtonState createState() => QuillToolbarLinkStyleButtonState createState() =>
_QuillToolbarLinkStyleButtonState(); QuillToolbarLinkStyleButtonState();
} }
class _QuillToolbarLinkStyleButtonState class QuillToolbarLinkStyleButtonState
extends State<QuillToolbarLinkStyleButton> { extends State<QuillToolbarLinkStyleButton> {
void _didChangeSelection() { void _didChangeSelection() {
setState(() {}); setState(() {});
@ -161,7 +161,7 @@ class _QuillToolbarLinkStyleButtonState
final link = _getLinkAttributeValue(); final link = _getLinkAttributeValue();
final index = controller.selection.start; final index = controller.selection.start;
var text; String? text;
if (link != null) { if (link != null) {
// text should be the link's corresponding text, not selection // text should be the link's corresponding text, not selection
final leaf = controller.document.querySegmentLeafNode(index).leaf; final leaf = controller.document.querySegmentLeafNode(index).leaf;

@ -448,7 +448,7 @@ class QuillTextLink {
controller.getSelectionStyle().attributes[Attribute.link.key]?.value; controller.getSelectionStyle().attributes[Attribute.link.key]?.value;
final index = controller.selection.start; final index = controller.selection.start;
var text; String? text;
if (link != null) { if (link != null) {
// text should be the link's corresponding text, not selection // text should be the link's corresponding text, not selection
final leaf = controller.document.querySegmentLeafNode(index).leaf; final leaf = controller.document.querySegmentLeafNode(index).leaf;

@ -13,8 +13,8 @@ class QuillToolbarIconButton extends StatelessWidget {
this.highlightElevation = 1, this.highlightElevation = 1,
this.borderRadius = 2, this.borderRadius = 2,
this.tooltip, this.tooltip,
Key? key, super.key,
}) : super(key: key); });
final VoidCallback? onPressed; final VoidCallback? onPressed;
final VoidCallback? afterPressed; final VoidCallback? afterPressed;

@ -52,11 +52,11 @@ class QuillToolbarSearchDialog extends StatefulWidget {
final QuillToolbarSearchDialogChildBuilder? childBuilder; final QuillToolbarSearchDialogChildBuilder? childBuilder;
@override @override
_QuillToolbarSearchDialogState createState() => QuillToolbarSearchDialogState createState() =>
_QuillToolbarSearchDialogState(); QuillToolbarSearchDialogState();
} }
class _QuillToolbarSearchDialogState extends State<QuillToolbarSearchDialog> { class QuillToolbarSearchDialogState extends State<QuillToolbarSearchDialog> {
late String _text; late String _text;
late TextEditingController _controller; late TextEditingController _controller;
late List<int>? _offsets; late List<int>? _offsets;
@ -217,7 +217,7 @@ class _QuillToolbarSearchDialogState extends State<QuillToolbarSearchDialog> {
baseOffset: _offsets![_index], baseOffset: _offsets![_index],
extentOffset: _offsets![_index] + _text.length, extentOffset: _offsets![_index] + _text.length,
), ),
ChangeSource.LOCAL, ChangeSource.local,
); );
} }

@ -32,11 +32,11 @@ class QuillToolbarSelectAlignmentButton extends StatefulWidget {
final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? padding;
@override @override
_QuillToolbarSelectAlignmentButtonState createState() => QuillToolbarSelectAlignmentButtonState createState() =>
_QuillToolbarSelectAlignmentButtonState(); QuillToolbarSelectAlignmentButtonState();
} }
class _QuillToolbarSelectAlignmentButtonState class QuillToolbarSelectAlignmentButtonState
extends State<QuillToolbarSelectAlignmentButton> { extends State<QuillToolbarSelectAlignmentButton> {
Attribute? _value; Attribute? _value;
@ -149,7 +149,7 @@ class _QuillToolbarSelectAlignmentButtonState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final _valueToText = <Attribute, String>{ final valueToText = <Attribute, String>{
if (widget.showLeftAlignment!) if (widget.showLeftAlignment!)
Attribute.leftAlignment: Attribute.leftAlignment.value!, Attribute.leftAlignment: Attribute.leftAlignment.value!,
if (widget.showCenterAlignment!) if (widget.showCenterAlignment!)
@ -160,13 +160,13 @@ class _QuillToolbarSelectAlignmentButtonState
Attribute.justifyAlignment: Attribute.justifyAlignment.value!, Attribute.justifyAlignment: Attribute.justifyAlignment.value!,
}; };
final _valueAttribute = <Attribute>[ final valueAttribute = <Attribute>[
if (widget.showLeftAlignment!) Attribute.leftAlignment, if (widget.showLeftAlignment!) Attribute.leftAlignment,
if (widget.showCenterAlignment!) Attribute.centerAlignment, if (widget.showCenterAlignment!) Attribute.centerAlignment,
if (widget.showRightAlignment!) Attribute.rightAlignment, if (widget.showRightAlignment!) Attribute.rightAlignment,
if (widget.showJustifyAlignment!) Attribute.justifyAlignment if (widget.showJustifyAlignment!) Attribute.justifyAlignment
]; ];
final _valueString = <String>[ final valueString = <String>[
if (widget.showLeftAlignment!) Attribute.leftAlignment.value!, if (widget.showLeftAlignment!) Attribute.leftAlignment.value!,
if (widget.showCenterAlignment!) Attribute.centerAlignment.value!, if (widget.showCenterAlignment!) Attribute.centerAlignment.value!,
if (widget.showRightAlignment!) Attribute.rightAlignment.value!, if (widget.showRightAlignment!) Attribute.rightAlignment.value!,
@ -191,12 +191,12 @@ class _QuillToolbarSelectAlignmentButtonState
final childBuilder = final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder; options.childBuilder ?? baseButtonExtraOptions.childBuilder;
void _sharedOnPressed(int index) { void sharedOnPressed(int index) {
_valueAttribute[index] == Attribute.leftAlignment valueAttribute[index] == Attribute.leftAlignment
? controller.formatSelection( ? controller.formatSelection(
Attribute.clone(Attribute.align, null), Attribute.clone(Attribute.align, null),
) )
: controller.formatSelection(_valueAttribute[index]); : controller.formatSelection(valueAttribute[index]);
_afterButtonPressed?.call(); _afterButtonPressed?.call();
} }
@ -215,7 +215,7 @@ class _QuillToolbarSelectAlignmentButtonState
QuillToolbarSelectAlignmentButtonExtraOptions( QuillToolbarSelectAlignmentButtonExtraOptions(
context: context, context: context,
controller: controller, controller: controller,
onPressed: () => _sharedOnPressed(index), onPressed: () => sharedOnPressed(index),
), ),
); );
} }
@ -229,11 +229,11 @@ class _QuillToolbarSelectAlignmentButtonState
height: _iconSize * kIconButtonFactor, height: _iconSize * kIconButtonFactor,
), ),
child: UtilityWidgets.maybeTooltip( child: UtilityWidgets.maybeTooltip(
message: _valueString[index] == Attribute.leftAlignment.value message: valueString[index] == Attribute.leftAlignment.value
? _tooltips.leftAlignment ? _tooltips.leftAlignment
: _valueString[index] == Attribute.centerAlignment.value : valueString[index] == Attribute.centerAlignment.value
? _tooltips.centerAlignment ? _tooltips.centerAlignment
: _valueString[index] == Attribute.rightAlignment.value : valueString[index] == Attribute.rightAlignment.value
? _tooltips.rightAlignment ? _tooltips.rightAlignment
: _tooltips.justifyAlignment, : _tooltips.justifyAlignment,
child: RawMaterialButton( child: RawMaterialButton(
@ -244,22 +244,21 @@ class _QuillToolbarSelectAlignmentButtonState
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius:
BorderRadius.circular(_iconTheme?.borderRadius ?? 2)), BorderRadius.circular(_iconTheme?.borderRadius ?? 2)),
fillColor: _valueToText[_value] == _valueString[index] fillColor: valueToText[_value] == valueString[index]
? (_iconTheme?.iconSelectedFillColor ?? theme.primaryColor) ? (_iconTheme?.iconSelectedFillColor ?? theme.primaryColor)
: (_iconTheme?.iconUnselectedFillColor ?? : (_iconTheme?.iconUnselectedFillColor ??
theme.canvasColor), theme.canvasColor),
onPressed: () => _sharedOnPressed(index), onPressed: () => sharedOnPressed(index),
child: Icon( child: Icon(
_valueString[index] == Attribute.leftAlignment.value valueString[index] == Attribute.leftAlignment.value
? _iconsData.leftAlignment ? _iconsData.leftAlignment
: _valueString[index] == Attribute.centerAlignment.value : valueString[index] == Attribute.centerAlignment.value
? _iconsData.centerAlignment ? _iconsData.centerAlignment
: _valueString[index] == : valueString[index] == Attribute.rightAlignment.value
Attribute.rightAlignment.value
? _iconsData.rightAlignment ? _iconsData.rightAlignment
: _iconsData.justifyAlignment, : _iconsData.justifyAlignment,
size: _iconSize, size: _iconSize,
color: _valueToText[_value] == _valueString[index] color: valueToText[_value] == valueString[index]
? (_iconTheme?.iconSelectedColor ?? ? (_iconTheme?.iconSelectedColor ??
theme.primaryIconTheme.color) theme.primaryIconTheme.color)
: (_iconTheme?.iconUnselectedColor ?? : (_iconTheme?.iconUnselectedColor ??

@ -21,11 +21,11 @@ class QuillToolbarSelectHeaderStyleButtons extends StatefulWidget {
final QuillToolbarSelectHeaderStyleButtonsOptions options; final QuillToolbarSelectHeaderStyleButtonsOptions options;
@override @override
_QuillToolbarSelectHeaderStyleButtonsState createState() => QuillToolbarSelectHeaderStyleButtonsState createState() =>
_QuillToolbarSelectHeaderStyleButtonsState(); QuillToolbarSelectHeaderStyleButtonsState();
} }
class _QuillToolbarSelectHeaderStyleButtonsState class QuillToolbarSelectHeaderStyleButtonsState
extends State<QuillToolbarSelectHeaderStyleButtons> { extends State<QuillToolbarSelectHeaderStyleButtons> {
Attribute? _selectedAttribute; Attribute? _selectedAttribute;
@ -85,9 +85,9 @@ class _QuillToolbarSelectHeaderStyleButtonsState
} }
void _sharedOnPressed(Attribute attribute) { void _sharedOnPressed(Attribute attribute) {
final _attribute = final attribute0 =
_selectedAttribute == attribute ? Attribute.header : attribute; _selectedAttribute == attribute ? Attribute.header : attribute;
controller.formatSelection(_attribute); controller.formatSelection(attribute0);
afterButtonPressed?.call(); afterButtonPressed?.call();
} }

@ -23,11 +23,11 @@ class QuillToolbarToggleCheckListButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
@override @override
_QuillToolbarToggleCheckListButtonState createState() => QuillToolbarToggleCheckListButtonState createState() =>
_QuillToolbarToggleCheckListButtonState(); QuillToolbarToggleCheckListButtonState();
} }
class _QuillToolbarToggleCheckListButtonState class QuillToolbarToggleCheckListButtonState
extends State<QuillToolbarToggleCheckListButton> { extends State<QuillToolbarToggleCheckListButton> {
bool? _isToggled; bool? _isToggled;

@ -36,11 +36,11 @@ class QuillToolbarToggleStyleButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
@override @override
_QuillToolbarToggleStyleButtonState createState() => QuillToolbarToggleStyleButtonState createState() =>
_QuillToolbarToggleStyleButtonState(); QuillToolbarToggleStyleButtonState();
} }
class _QuillToolbarToggleStyleButtonState class QuillToolbarToggleStyleButtonState
extends State<QuillToolbarToggleStyleButton> { extends State<QuillToolbarToggleStyleButton> {
bool? _isToggled; bool? _isToggled;

@ -1,6 +1,6 @@
name: flutter_quill name: flutter_quill
description: A rich text editor built for the modern Android, iOS, web and desktop platforms. It is the WYSIWYG editor and a Quill component for Flutter. description: A rich text editor built for the modern Android, iOS, web and desktop platforms. It is the WYSIWYG editor and a Quill component for Flutter.
version: 8.1.10 version: 8.1.11
homepage: https://1o24bbs.com/c/bulletjournal/108 homepage: https://1o24bbs.com/c/bulletjournal/108
repository: https://github.com/singerdmx/flutter-quill repository: https://github.com/singerdmx/flutter-quill
@ -42,12 +42,10 @@ dependencies:
flutter_keyboard_visibility: ^5.4.1 flutter_keyboard_visibility: ^5.4.1
quiver: ^3.2.1 quiver: ^3.2.1
url_launcher: ^6.1.14 url_launcher: ^6.1.14
pedantic: ^1.11.1
characters: ^1.3.0 characters: ^1.3.0
diff_match_patch: ^0.4.1 diff_match_patch: ^0.4.1
i18n_extension: ^9.0.2 i18n_extension: ^9.0.2
device_info_plus: ^9.1.0 device_info_plus: ^9.1.0
platform: ^3.1.0
pasteboard: ^0.2.0 pasteboard: ^0.2.0
equatable: ^2.0.5 equatable: ^2.0.5
flutter_animate: ^4.2.0+1 flutter_animate: ^4.2.0+1
@ -56,4 +54,7 @@ dependencies:
sdk: flutter sdk: flutter
meta: ^1.9.1 meta: ^1.9.1
flutter: null flutter:
uses-material-design: true
dev_dependencies:
lints: ^3.0.0

@ -9,7 +9,7 @@ void main() {
setUp(() { setUp(() {
controller = QuillController.basic() controller = QuillController.basic()
..compose(Delta()..insert(testDocumentContents), ..compose(Delta()..insert(testDocumentContents),
const TextSelection.collapsed(offset: 0), ChangeSource.LOCAL); const TextSelection.collapsed(offset: 0), ChangeSource.local);
}); });
group('controller', () { group('controller', () {
@ -31,7 +31,7 @@ void main() {
controller controller
..formatText(0, 5, Attribute.h1) ..formatText(0, 5, Attribute.h1)
..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 4), ..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 4),
ChangeSource.LOCAL); ChangeSource.local);
expect(controller.getSelectionStyle().values, [Attribute.h1]); expect(controller.getSelectionStyle().values, [Attribute.h1]);
}); });
@ -41,7 +41,7 @@ void main() {
// With selection range // With selection range
controller controller
..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 4), ..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 4),
ChangeSource.LOCAL) ChangeSource.local)
..addListener(() { ..addListener(() {
listenerCalled = true; listenerCalled = true;
}) })
@ -58,12 +58,12 @@ void main() {
// With collapsed selection // With collapsed selection
controller controller
..updateSelection( ..updateSelection(
const TextSelection.collapsed(offset: 0), ChangeSource.LOCAL) const TextSelection.collapsed(offset: 0), ChangeSource.local)
..indentSelection(true); ..indentSelection(true);
expect(controller.getSelectionStyle().values, [Attribute.indentL1]); expect(controller.getSelectionStyle().values, [Attribute.indentL1]);
controller controller
..updateSelection( ..updateSelection(
const TextSelection.collapsed(offset: 0), ChangeSource.LOCAL) const TextSelection.collapsed(offset: 0), ChangeSource.local)
..indentSelection(true); ..indentSelection(true);
expect(controller.getSelectionStyle().values, [Attribute.indentL2]); expect(controller.getSelectionStyle().values, [Attribute.indentL2]);
controller.indentSelection(false); controller.indentSelection(false);
@ -75,17 +75,17 @@ void main() {
test('indentSelection with multiline document', () { test('indentSelection with multiline document', () {
controller controller
..compose(Delta()..insert('line1\nline2\nline3\n'), ..compose(Delta()..insert('line1\nline2\nline3\n'),
const TextSelection.collapsed(offset: 0), ChangeSource.LOCAL) const TextSelection.collapsed(offset: 0), ChangeSource.local)
// Indent first line // Indent first line
..updateSelection( ..updateSelection(
const TextSelection.collapsed(offset: 0), ChangeSource.LOCAL) const TextSelection.collapsed(offset: 0), ChangeSource.local)
..indentSelection(true); ..indentSelection(true);
expect(controller.getSelectionStyle().values, [Attribute.indentL1]); expect(controller.getSelectionStyle().values, [Attribute.indentL1]);
// Indent first two lines // Indent first two lines
controller controller
..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 11), ..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 11),
ChangeSource.LOCAL) ChangeSource.local)
..indentSelection(true); ..indentSelection(true);
// Should have both L1 and L2 indent attributes in selection. // Should have both L1 and L2 indent attributes in selection.
@ -101,7 +101,7 @@ void main() {
TextSelection( TextSelection(
baseOffset: 12, baseOffset: 12,
extentOffset: controller.document.toPlainText().length - 1), extentOffset: controller.document.toPlainText().length - 1),
ChangeSource.LOCAL); ChangeSource.local);
expect(controller.getAllSelectionStyles(), everyElement(const Style())); expect(controller.getAllSelectionStyles(), everyElement(const Style()));
}); });
@ -110,7 +110,7 @@ void main() {
..formatText(0, 2, Attribute.bold) ..formatText(0, 2, Attribute.bold)
..replaceText(2, 2, BlockEmbed.image('/test'), null) ..replaceText(2, 2, BlockEmbed.image('/test'), null)
..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 4), ..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 4),
ChangeSource.REMOTE); ChangeSource.remote);
final result = controller.getAllIndividualSelectionStylesAndEmbed(); final result = controller.getAllIndividualSelectionStylesAndEmbed();
expect(result.length, 2); expect(result.length, 2);
expect(result[0].offset, 0); expect(result[0].offset, 0);
@ -121,7 +121,7 @@ void main() {
test('getPlainText', () { test('getPlainText', () {
controller.updateSelection( controller.updateSelection(
const TextSelection(baseOffset: 0, extentOffset: 4), const TextSelection(baseOffset: 0, extentOffset: 4),
ChangeSource.LOCAL); ChangeSource.local);
expect(controller.getPlainText(), testDocumentContents); expect(controller.getPlainText(), testDocumentContents);
}); });
@ -135,7 +135,7 @@ void main() {
test('undo', () { test('undo', () {
var listenerCalled = false; var listenerCalled = false;
controller.updateSelection( controller.updateSelection(
const TextSelection.collapsed(offset: 4), ChangeSource.LOCAL); const TextSelection.collapsed(offset: 4), ChangeSource.local);
expect( expect(
controller.document.toDelta(), controller.document.toDelta(),
@ -153,7 +153,7 @@ void main() {
test('redo', () { test('redo', () {
var listenerCalled = false; var listenerCalled = false;
controller.updateSelection( controller.updateSelection(
const TextSelection.collapsed(offset: 4), ChangeSource.LOCAL); const TextSelection.collapsed(offset: 4), ChangeSource.local);
expect(controller.document.toDelta(), Delta()..insert('data\n')); expect(controller.document.toDelta(), Delta()..insert('data\n'));
controller.undo(); controller.undo();
@ -222,7 +222,7 @@ void main() {
var listenerCalled = false; var listenerCalled = false;
controller controller
..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 2), ..updateSelection(const TextSelection(baseOffset: 0, extentOffset: 2),
ChangeSource.LOCAL) ChangeSource.local)
..addListener(() { ..addListener(() {
listenerCalled = true; listenerCalled = true;
}) })
@ -238,7 +238,7 @@ void main() {
var listenerCalled = false; var listenerCalled = false;
controller controller
..updateSelection( ..updateSelection(
const TextSelection.collapsed(offset: 4), ChangeSource.LOCAL) const TextSelection.collapsed(offset: 4), ChangeSource.local)
..addListener(() { ..addListener(() {
listenerCalled = true; listenerCalled = true;
}); });
@ -281,7 +281,7 @@ void main() {
..addListener(() { ..addListener(() {
listenerCalled = true; listenerCalled = true;
}) })
..updateSelection(selection, ChangeSource.LOCAL); ..updateSelection(selection, ChangeSource.local);
expect(listenerCalled, isTrue); expect(listenerCalled, isTrue);
expect(controller.selection, selection); expect(controller.selection, selection);
@ -295,7 +295,7 @@ void main() {
listenerCalled = true; listenerCalled = true;
}) })
..compose(Delta()..insert('test '), ..compose(Delta()..insert('test '),
const TextSelection.collapsed(offset: 0), ChangeSource.LOCAL); const TextSelection.collapsed(offset: 0), ChangeSource.local);
expect(listenerCalled, isTrue); expect(listenerCalled, isTrue);
expect(controller.document.toDelta(), expect(controller.document.toDelta(),

Loading…
Cancel
Save