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]
- 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:
errors:

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

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

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

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

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

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

@ -30,7 +30,7 @@ class Embeddable {
/// the document model itself does not make any assumptions about the types
/// of embedded objects and allows users to define their own types.
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 BlockEmbed image(String imageUrl) => BlockEmbed(imageType, imageUrl);
@ -47,7 +47,7 @@ class BlockEmbed extends Embeddable {
}
class CustomBlockEmbed extends BlockEmbed {
const CustomBlockEmbed(String type, String data) : super(type, data);
const CustomBlockEmbed(super.type, super.data);
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
///
base class QuillText extends Leaf {
QuillText([String text = ''])
QuillText([String super.text = ''])
: assert(!text.contains('\n')),
super.val(text);
super.val();
@override
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
/// an image actually makes the image react to user's action.
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
static const kObjectReplacementCharacter = '\uFFFC';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -294,14 +294,14 @@ class _TextLineState extends State<TextLine> {
if (widget.customStyleBuilder == null) {
return textStyle;
}
attributes.keys.forEach((key) {
for (final key in attributes.keys) {
final attr = attributes[key];
if (attr != null) {
/// Custom Attribute
final customAttr = widget.customStyleBuilder!.call(attr);
textStyle = textStyle.merge(customAttr);
}
});
}
return textStyle;
}
@ -1292,7 +1292,7 @@ class RenderEditableTextLine extends RenderEditableBox {
}
class _TextLineElement extends RenderObjectElement {
_TextLineElement(EditableTextLine line) : super(line);
_TextLineElement(EditableTextLine super.line);
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
/// [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
class DragTextSelection extends TextSelection {
const DragTextSelection({
TextAffinity affinity = TextAffinity.downstream,
int baseOffset = 0,
int extentOffset = 0,
bool isDirectional = false,
super.affinity,
super.baseOffset = 0,
super.extentOffset = 0,
super.isDirectional,
this.first = true,
}) : super(
baseOffset: baseOffset,
extentOffset: extentOffset,
affinity: affinity,
isDirectional: isDirectional,
);
});
final bool first;
@ -236,7 +231,7 @@ class EditorTextSelectionOverlay {
Widget _buildHandle(
BuildContext context, _TextSelectionHandlePosition position) {
if (_selection.isCollapsed &&
position == _TextSelectionHandlePosition.END) {
position == _TextSelectionHandlePosition.end) {
return Container();
}
return Visibility(
@ -282,12 +277,12 @@ class EditorTextSelectionOverlay {
TextSelection? newSelection, _TextSelectionHandlePosition position) {
TextPosition textPosition;
switch (position) {
case _TextSelectionHandlePosition.START:
case _TextSelectionHandlePosition.start:
textPosition = newSelection != null
? newSelection.base
: const TextPosition(offset: 0);
break;
case _TextSelectionHandlePosition.END:
case _TextSelectionHandlePosition.end:
textPosition = newSelection != null
? newSelection.extent
: const TextPosition(offset: 0);
@ -302,7 +297,7 @@ class EditorTextSelectionOverlay {
extentOffset: newSelection.extentOffset,
affinity: newSelection.affinity,
isDirectional: newSelection.isDirectional,
first: position == _TextSelectionHandlePosition.START,
first: position == _TextSelectionHandlePosition.start,
)
: null;
@ -344,10 +339,10 @@ class EditorTextSelectionOverlay {
_handles = <OverlayEntry>[
OverlayEntry(
builder: (context) =>
_buildHandle(context, _TextSelectionHandlePosition.START)),
_buildHandle(context, _TextSelectionHandlePosition.start)),
OverlayEntry(
builder: (context) =>
_buildHandle(context, _TextSelectionHandlePosition.END)),
_buildHandle(context, _TextSelectionHandlePosition.end)),
];
Overlay.of(context, rootOverlay: true, debugRequiredFor: debugRequiredFor)
@ -375,8 +370,7 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
required this.onSelectionHandleTapped,
required this.selectionControls,
this.dragStartBehavior = DragStartBehavior.start,
Key? key,
}) : super(key: key);
});
final TextSelection selection;
final _TextSelectionHandlePosition position;
@ -394,9 +388,9 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
ValueListenable<bool> get _visibility {
switch (position) {
case _TextSelectionHandlePosition.START:
case _TextSelectionHandlePosition.start:
return renderObject.selectionStartInViewport;
case _TextSelectionHandlePosition.END:
case _TextSelectionHandlePosition.end:
return renderObject.selectionEndInViewport;
default:
throw 'Invalid position';
@ -449,7 +443,7 @@ class _TextSelectionHandleOverlayState
}
void _handleDragStart(DragStartDetails details) {
final textPosition = widget.position == _TextSelectionHandlePosition.START
final textPosition = widget.position == _TextSelectionHandlePosition.start
? widget.selection.base
: widget.selection.extent;
final lineHeight = widget.renderObject.preferredLineHeight(textPosition);
@ -470,7 +464,7 @@ class _TextSelectionHandleOverlayState
widget.selection.extentOffset >= widget.selection.baseOffset;
TextSelection newSelection;
switch (widget.position) {
case _TextSelectionHandlePosition.START:
case _TextSelectionHandlePosition.start:
newSelection = TextSelection(
baseOffset:
isNormalized ? position.offset : widget.selection.baseOffset,
@ -478,7 +472,7 @@ class _TextSelectionHandleOverlayState
isNormalized ? widget.selection.extentOffset : position.offset,
);
break;
case _TextSelectionHandlePosition.END:
case _TextSelectionHandlePosition.end:
newSelection = TextSelection(
baseOffset:
isNormalized ? widget.selection.baseOffset : position.offset,
@ -507,7 +501,7 @@ class _TextSelectionHandleOverlayState
TextSelectionHandleType? type;
switch (widget.position) {
case _TextSelectionHandlePosition.START:
case _TextSelectionHandlePosition.start:
layerLink = widget.startHandleLayerLink;
type = _chooseType(
widget.renderObject.textDirection,
@ -515,7 +509,7 @@ class _TextSelectionHandleOverlayState
TextSelectionHandleType.right,
);
break;
case _TextSelectionHandlePosition.END:
case _TextSelectionHandlePosition.end:
// For collapsed selections, we shouldn't be building the [end] handle.
assert(!widget.selection.isCollapsed);
layerLink = widget.endHandleLayerLink;
@ -533,7 +527,7 @@ class _TextSelectionHandleOverlayState
// May have to use getSelectionBoxes instead of preferredLineHeight.
// or expose TextStyle on the render object and calculate
// preferredLineHeight / style.height
final textPosition = widget.position == _TextSelectionHandlePosition.START
final textPosition = widget.position == _TextSelectionHandlePosition.start
? widget.selection.base
: widget.selection.extent;
final lineHeight = widget.renderObject.preferredLineHeight(textPosition);
@ -649,8 +643,8 @@ class EditorTextSelectionGestureDetector extends StatefulWidget {
this.onDragSelectionEnd,
this.behavior,
this.detectWordBoundary = true,
Key? key,
}) : super(key: key);
super.key,
});
/// 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
@ -1001,8 +995,8 @@ class _EditorTextSelectionGestureDetectorState
// underlying input.
class _TransparentTapGestureRecognizer extends TapGestureRecognizer {
_TransparentTapGestureRecognizer({
Object? debugOwner,
}) : super(debugOwner: debugOwner);
super.debugOwner,
});
@override
void rejectGesture(int pointer) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,6 +1,6 @@
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.
version: 8.1.10
version: 8.1.11
homepage: https://1o24bbs.com/c/bulletjournal/108
repository: https://github.com/singerdmx/flutter-quill
@ -42,12 +42,10 @@ dependencies:
flutter_keyboard_visibility: ^5.4.1
quiver: ^3.2.1
url_launcher: ^6.1.14
pedantic: ^1.11.1
characters: ^1.3.0
diff_match_patch: ^0.4.1
i18n_extension: ^9.0.2
device_info_plus: ^9.1.0
platform: ^3.1.0
pasteboard: ^0.2.0
equatable: ^2.0.5
flutter_animate: ^4.2.0+1
@ -56,4 +54,7 @@ dependencies:
sdk: flutter
meta: ^1.9.1
flutter: null
flutter:
uses-material-design: true
dev_dependencies:
lints: ^3.0.0

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

Loading…
Cancel
Save