Clear hints

pull/110/head
Xin Yao 4 years ago
parent 811cb341bf
commit 718912bc29
  1. 10
      lib/models/documents/nodes/container.dart
  2. 16
      lib/models/documents/nodes/leaf.dart
  3. 20
      lib/models/documents/nodes/line.dart
  4. 8
      lib/models/documents/nodes/node.dart
  5. 4
      lib/models/rules/delete.dart
  6. 4
      lib/models/rules/format.dart
  7. 12
      lib/models/rules/insert.dart
  8. 6
      lib/models/rules/rule.dart
  9. 2
      lib/utils/color.dart
  10. 2
      lib/utils/universal_ui/fake_ui.dart
  11. 2
      lib/utils/universal_ui/real_ui.dart
  12. 2
      lib/utils/universal_ui/universal_ui.dart
  13. 18
      lib/widgets/controller.dart
  14. 14
      lib/widgets/cursor.dart
  15. 36
      lib/widgets/default_styles.dart
  16. 4
      lib/widgets/delegate.dart
  17. 60
      lib/widgets/editor.dart
  18. 4
      lib/widgets/proxy.dart
  19. 46
      lib/widgets/raw_editor.dart
  20. 70
      lib/widgets/text_block.dart
  21. 64
      lib/widgets/text_line.dart
  22. 2
      pubspec.yaml

@ -25,13 +25,13 @@ abstract class Container<T extends Node?> extends Node {
/// abstract methods end /// abstract methods end
add(T node) { void add(T node) {
assert(node?.parent == null); assert(node?.parent == null);
node?.parent = this; node?.parent = this;
_children.add(node as Node); _children.add(node as Node);
} }
addFirst(T node) { void addFirst(T node) {
assert(node?.parent == null); assert(node?.parent == null);
node?.parent = this; node?.parent = this;
_children.addFirst(node as Node); _children.addFirst(node as Node);
@ -80,7 +80,7 @@ abstract class Container<T extends Node?> extends Node {
int get length => _children.fold(0, (cur, node) => cur + node.length); int get length => _children.fold(0, (cur, node) => cur + node.length);
@override @override
insert(int index, Object data, Style? style) { void insert(int index, Object data, Style? style) {
assert(index == 0 || (index > 0 && index < length)); assert(index == 0 || (index > 0 && index < length));
if (isNotEmpty) { if (isNotEmpty) {
@ -97,14 +97,14 @@ abstract class Container<T extends Node?> extends Node {
} }
@override @override
retain(int index, int? length, Style? attributes) { void retain(int index, int? length, Style? attributes) {
assert(isNotEmpty); assert(isNotEmpty);
ChildQuery child = queryChild(index, false); ChildQuery child = queryChild(index, false);
child.node!.retain(child.offset, length, attributes); child.node!.retain(child.offset, length, attributes);
} }
@override @override
delete(int index, int? length) { void delete(int index, int? length) {
assert(isNotEmpty); assert(isNotEmpty);
ChildQuery child = queryChild(index, false); ChildQuery child = queryChild(index, false);
child.node!.delete(child.offset, length); child.node!.delete(child.offset, length);

@ -50,7 +50,7 @@ abstract class Leaf extends Node {
} }
@override @override
insert(int index, Object data, Style? style) { void insert(int index, Object data, Style? style) {
assert(index >= 0 && index <= length); assert(index >= 0 && index <= length);
Leaf node = Leaf(data); Leaf node = Leaf(data);
if (index < length) { if (index < length) {
@ -62,12 +62,12 @@ abstract class Leaf extends Node {
} }
@override @override
retain(int index, int? len, Style? style) { void retain(int index, int? len, Style? style) {
if (style == null) { if (style == null) {
return; return;
} }
int local = math.min(this.length - index, len!); int local = math.min(length - index, len!);
int remain = len - local; int remain = len - local;
Leaf node = _isolate(index, local); Leaf node = _isolate(index, local);
@ -79,10 +79,10 @@ abstract class Leaf extends Node {
} }
@override @override
delete(int index, int? len) { void delete(int index, int? len) {
assert(index < this.length); assert(index < length);
int local = math.min(this.length - index, len!); int local = math.min(length - index, len!);
Leaf target = _isolate(index, local); Leaf target = _isolate(index, local);
Leaf? prev = target.previous as Leaf?; Leaf? prev = target.previous as Leaf?;
Leaf? next = target.next as Leaf?; Leaf? next = target.next as Leaf?;
@ -100,7 +100,7 @@ abstract class Leaf extends Node {
} }
@override @override
adjust() { void adjust() {
if (this is Embed) { if (this is Embed) {
return; return;
} }
@ -147,7 +147,7 @@ abstract class Leaf extends Node {
return split; return split;
} }
format(Style? style) { void format(Style? style) {
if (style != null && style.isNotEmpty) { if (style != null && style.isNotEmpty) {
applyStyle(style); applyStyle(style);
} }

@ -66,7 +66,7 @@ class Line extends Container<Leaf?> {
} }
@override @override
insert(int index, Object data, Style? style) { void insert(int index, Object data, Style? style) {
if (data is Embeddable) { if (data is Embeddable) {
_insert(index, data, style); _insert(index, data, style);
return; return;
@ -101,11 +101,11 @@ class Line extends Container<Leaf?> {
} }
@override @override
retain(int index, int? len, Style? style) { void retain(int index, int? len, Style? style) {
if (style == null) { if (style == null) {
return; return;
} }
int thisLen = this.length; int thisLen = length;
int local = math.min(thisLen - index, len!); int local = math.min(thisLen - index, len!);
@ -126,9 +126,9 @@ class Line extends Container<Leaf?> {
} }
@override @override
delete(int index, int? len) { void delete(int index, int? len) {
int local = math.min(this.length - index, len!); int local = math.min(length - index, len!);
bool deleted = index + local == this.length; bool deleted = index + local == length;
if (deleted) { if (deleted) {
clearStyle(); clearStyle();
if (local > 1) { if (local > 1) {
@ -187,14 +187,14 @@ class Line extends Container<Leaf?> {
} }
} }
_wrap(Block block) { void _wrap(Block block) {
assert(parent != null && parent is! Block); assert(parent != null && parent is! Block);
insertAfter(block); insertAfter(block);
unlink(); unlink();
block.add(this); block.add(this);
} }
_unwrap() { void _unwrap() {
if (parent is! Block) { if (parent is! Block) {
throw ArgumentError('Invalid parent'); throw ArgumentError('Invalid parent');
} }
@ -246,7 +246,7 @@ class Line extends Container<Leaf?> {
return line; return line;
} }
_insert(int index, Object data, Style? style) { void _insert(int index, Object data, Style? style) {
assert(index == 0 || (index > 0 && index < length)); assert(index == 0 || (index > 0 && index < length));
if (data is String) { if (data is String) {
@ -273,7 +273,7 @@ class Line extends Container<Leaf?> {
} }
Style collectStyle(int offset, int len) { Style collectStyle(int offset, int len) {
int local = math.min(this.length - offset, len); int local = math.min(length - offset, len);
Style res = Style(); Style res = Style();
var excluded = <Attribute>{}; var excluded = <Attribute>{};

@ -84,7 +84,7 @@ abstract class Node extends LinkedListEntry<Node> {
super.unlink(); super.unlink();
} }
adjust() { void adjust() {
// do nothing // do nothing
} }
@ -96,11 +96,11 @@ abstract class Node extends LinkedListEntry<Node> {
Delta toDelta(); Delta toDelta();
insert(int index, Object data, Style? style); void insert(int index, Object data, Style? style);
retain(int index, int? len, Style? style); void retain(int index, int? len, Style? style);
delete(int index, int? len); void delete(int index, int? len);
/// abstract methods end /// abstract methods end

@ -9,7 +9,7 @@ abstract class DeleteRule extends Rule {
RuleType get type => RuleType.DELETE; RuleType get type => RuleType.DELETE;
@override @override
validateArgs(int? len, Object? data, Attribute? attribute) { void validateArgs(int? len, Object? data, Attribute? attribute) {
assert(len != null); assert(len != null);
assert(data == null); assert(data == null);
assert(attribute == null); assert(attribute == null);
@ -54,7 +54,7 @@ class PreserveLineStyleOnMergeRule extends DeleteRule {
String text = op.data is String ? (op.data as String?)! : ''; String text = op.data is String ? (op.data as String?)! : '';
int lineBreak = text.indexOf('\n'); int lineBreak = text.indexOf('\n');
if (lineBreak == -1) { if (lineBreak == -1) {
delta..retain(op.length!); delta.retain(op.length!);
continue; continue;
} }

@ -9,7 +9,7 @@ abstract class FormatRule extends Rule {
RuleType get type => RuleType.FORMAT; RuleType get type => RuleType.FORMAT;
@override @override
validateArgs(int? len, Object? data, Attribute? attribute) { void validateArgs(int? len, Object? data, Attribute? attribute) {
assert(len != null); assert(len != null);
assert(data == null); assert(data == null);
assert(attribute != null); assert(attribute != null);
@ -55,7 +55,7 @@ class ResolveLineFormatRule extends FormatRule {
String text = op.data is String ? (op.data as String?)! : ''; String text = op.data is String ? (op.data as String?)! : '';
int lineBreak = text.indexOf('\n'); int lineBreak = text.indexOf('\n');
if (lineBreak < 0) { if (lineBreak < 0) {
delta..retain(op.length!); delta.retain(op.length!);
continue; continue;
} }
delta..retain(lineBreak)..retain(1, attribute.toJson()); delta..retain(lineBreak)..retain(1, attribute.toJson());

@ -11,7 +11,7 @@ abstract class InsertRule extends Rule {
RuleType get type => RuleType.INSERT; RuleType get type => RuleType.INSERT;
@override @override
validateArgs(int? len, Object? data, Attribute? attribute) { void validateArgs(int? len, Object? data, Attribute? attribute) {
assert(len == null); assert(len == null);
assert(data != null); assert(data != null);
assert(attribute == null); assert(attribute == null);
@ -45,7 +45,7 @@ class PreserveLineStyleOnSplitRule extends InsertRule {
Delta delta = Delta()..retain(index); Delta delta = Delta()..retain(index);
if (text.contains('\n')) { if (text.contains('\n')) {
assert(after.isPlain); assert(after.isPlain);
delta..insert('\n'); delta.insert('\n');
return delta; return delta;
} }
Tuple2<Operation?, int?> nextNewLine = _getNextNewLine(itr); Tuple2<Operation?, int?> nextNewLine = _getNextNewLine(itr);
@ -222,7 +222,7 @@ class InsertEmbedsRule extends InsertRule {
} else { } else {
while (itr.hasNext) { while (itr.hasNext) {
Operation op = itr.next(); Operation op = itr.next();
if ((op.data is String ? op.data as String? : '')!.indexOf('\n') >= 0) { if ((op.data is String ? op.data as String? : '')!.contains('\n')) {
lineStyle = op.attributes; lineStyle = op.attributes;
break; break;
} }
@ -230,11 +230,11 @@ class InsertEmbedsRule extends InsertRule {
} }
if (!isNewlineBefore) { if (!isNewlineBefore) {
delta..insert('\n', lineStyle); delta.insert('\n', lineStyle);
} }
delta..insert(data); delta.insert(data);
if (!isNewlineAfter) { if (!isNewlineAfter) {
delta..insert('\n'); delta.insert('\n');
} }
return delta; return delta;
} }

@ -18,7 +18,7 @@ abstract class Rule {
len: len, data: data, attribute: attribute); len: len, data: data, attribute: attribute);
} }
validateArgs(int? len, Object? data, Attribute? attribute); void validateArgs(int? len, Object? data, Attribute? attribute);
Delta? applyRule(Delta document, int index, Delta? applyRule(Delta document, int index,
{int? len, Object? data, Attribute? attribute}); {int? len, Object? data, Attribute? attribute});
@ -61,11 +61,11 @@ class Rules {
final result = rule.apply(delta, index, final result = rule.apply(delta, index,
len: len, data: data, attribute: attribute); len: len, data: data, attribute: attribute);
if (result != null) { if (result != null) {
print("Rule $rule applied"); print('Rule $rule applied');
return result..trim(); return result..trim();
} }
} catch (e) { } catch (e) {
throw e; rethrow;
} }
} }
throw ('Apply rules failed'); throw ('Apply rules failed');

@ -115,7 +115,7 @@ Color stringToColor(String? s) {
} }
if (!s.startsWith('#')) { if (!s.startsWith('#')) {
throw ("Color code not supported"); throw ('Color code not supported');
} }
String hex = s.replaceFirst('#', ''); String hex = s.replaceFirst('#', '');

@ -1,3 +1,3 @@
class PlatformViewRegistry { class PlatformViewRegistry {
static registerViewFactory(String viewId, dynamic cb) {} static void registerViewFactory(String viewId, dynamic cb) {}
} }

@ -1,7 +1,7 @@
import 'dart:ui' as ui; import 'dart:ui' as ui;
class PlatformViewRegistry { class PlatformViewRegistry {
static registerViewFactory(String viewId, dynamic cb) { static void registerViewFactory(String viewId, dynamic cb) {
ui.platformViewRegistry.registerViewFactory(viewId, cb); ui.platformViewRegistry.registerViewFactory(viewId, cb);
} }
} }

@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart';
import 'fake_ui.dart' if (dart.library.html) 'real_ui.dart' as ui_instance; import 'fake_ui.dart' if (dart.library.html) 'real_ui.dart' as ui_instance;
class PlatformViewRegistryFix { class PlatformViewRegistryFix {
registerViewFactory(dynamic x, dynamic y) { void registerViewFactory(dynamic x, dynamic y) {
if (kIsWeb) { if (kIsWeb) {
ui_instance.PlatformViewRegistry.registerViewFactory( ui_instance.PlatformViewRegistry.registerViewFactory(
x, x,

@ -54,7 +54,7 @@ class QuillController extends ChangeNotifier {
// updateSelection( // updateSelection(
// TextSelection.collapsed(offset: document.length), ChangeSource.LOCAL); // TextSelection.collapsed(offset: document.length), ChangeSource.LOCAL);
updateSelection( updateSelection(
TextSelection.collapsed(offset: this.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
@ -73,7 +73,7 @@ class QuillController extends ChangeNotifier {
get hasRedo => document.hasRedo; get hasRedo => document.hasRedo;
replaceText(int index, int len, Object? data, TextSelection? textSelection) { void replaceText(int index, int len, Object? data, TextSelection? textSelection) {
assert(data is String || data is Embeddable); assert(data is String || data is Embeddable);
Delta? delta; Delta? delta;
@ -82,7 +82,7 @@ class QuillController extends ChangeNotifier {
delta = document.replace(index, len, data); delta = document.replace(index, len, data);
} catch (e) { } catch (e) {
print('document.replace failed: $e'); print('document.replace failed: $e');
throw e; rethrow;
} }
bool shouldRetainDelta = toggledStyle.isNotEmpty && bool shouldRetainDelta = toggledStyle.isNotEmpty &&
delta.isNotEmpty && delta.isNotEmpty &&
@ -127,14 +127,14 @@ class QuillController extends ChangeNotifier {
); );
} catch (e) { } catch (e) {
print('getPositionDelta or getPositionDelta error: $e'); print('getPositionDelta or getPositionDelta error: $e');
throw e; rethrow;
} }
} }
} }
notifyListeners(); notifyListeners();
} }
formatText(int index, int len, Attribute? attribute) { void formatText(int index, int len, Attribute? attribute) {
if (len == 0 && if (len == 0 &&
attribute!.isInline && attribute!.isInline &&
attribute.key != Attribute.link.key) { attribute.key != Attribute.link.key) {
@ -151,16 +151,16 @@ class QuillController extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
formatSelection(Attribute? attribute) { void formatSelection(Attribute? attribute) {
formatText(selection.start, selection.end - selection.start, attribute); formatText(selection.start, selection.end - selection.start, attribute);
} }
updateSelection(TextSelection textSelection, ChangeSource source) { void updateSelection(TextSelection textSelection, ChangeSource source) {
_updateSelection(textSelection, source); _updateSelection(textSelection, source);
notifyListeners(); notifyListeners();
} }
compose(Delta delta, TextSelection textSelection, ChangeSource source) { void compose(Delta delta, TextSelection textSelection, ChangeSource source) {
if (delta.isNotEmpty) { if (delta.isNotEmpty) {
document.compose(delta, source); document.compose(delta, source);
} }
@ -182,7 +182,7 @@ class QuillController extends ChangeNotifier {
super.dispose(); super.dispose();
} }
_updateSelection(TextSelection textSelection, ChangeSource source) { void _updateSelection(TextSelection textSelection, ChangeSource source) {
selection = textSelection; selection = textSelection;
int end = document.length - 1; int end = document.length - 1;
selection = selection.copyWith( selection = selection.copyWith(

@ -89,7 +89,7 @@ class CursorCont extends ChangeNotifier {
} }
@override @override
dispose() { void dispose() {
_blinkOpacityCont.removeListener(_onColorTick); _blinkOpacityCont.removeListener(_onColorTick);
stopCursorTimer(); stopCursorTimer();
_blinkOpacityCont.dispose(); _blinkOpacityCont.dispose();
@ -97,7 +97,7 @@ class CursorCont extends ChangeNotifier {
super.dispose(); super.dispose();
} }
_cursorTick(Timer timer) { void _cursorTick(Timer timer) {
_targetCursorVisibility = !_targetCursorVisibility; _targetCursorVisibility = !_targetCursorVisibility;
double targetOpacity = _targetCursorVisibility ? 1.0 : 0.0; double targetOpacity = _targetCursorVisibility ? 1.0 : 0.0;
if (style.opacityAnimates) { if (style.opacityAnimates) {
@ -107,7 +107,7 @@ class CursorCont extends ChangeNotifier {
} }
} }
_cursorWaitForStart(Timer timer) { void _cursorWaitForStart(Timer timer) {
_cursorTimer?.cancel(); _cursorTimer?.cancel();
_cursorTimer = Timer.periodic(Duration(milliseconds: 500), _cursorTick); _cursorTimer = Timer.periodic(Duration(milliseconds: 500), _cursorTick);
} }
@ -124,7 +124,7 @@ class CursorCont extends ChangeNotifier {
} }
} }
stopCursorTimer({bool resetCharTicks = true}) { void stopCursorTimer({bool resetCharTicks = true}) {
_cursorTimer?.cancel(); _cursorTimer?.cancel();
_cursorTimer = null; _cursorTimer = null;
_targetCursorVisibility = false; _targetCursorVisibility = false;
@ -136,7 +136,7 @@ class CursorCont extends ChangeNotifier {
} }
} }
startOrStopCursorTimerIfNeeded(bool hasFocus, TextSelection selection) { void startOrStopCursorTimerIfNeeded(bool hasFocus, TextSelection selection) {
if (show.value && if (show.value &&
_cursorTimer == null && _cursorTimer == null &&
hasFocus && hasFocus &&
@ -147,7 +147,7 @@ class CursorCont extends ChangeNotifier {
} }
} }
_onColorTick() { void _onColorTick() {
color.value = _style.color.withOpacity(_blinkOpacityCont.value); color.value = _style.color.withOpacity(_blinkOpacityCont.value);
_blink.value = show.value && _blinkOpacityCont.value > 0; _blink.value = show.value && _blinkOpacityCont.value > 0;
} }
@ -163,7 +163,7 @@ class CursorPainter {
CursorPainter(this.editable, this.style, this.prototype, this.color, CursorPainter(this.editable, this.style, this.prototype, this.color,
this.devicePixelRatio); this.devicePixelRatio);
paint(Canvas canvas, Offset offset, TextPosition position) { void paint(Canvas canvas, Offset offset, TextPosition position) {
assert(prototype != null); assert(prototype != null);
Offset caretOffset = Offset caretOffset =

@ -188,23 +188,23 @@ class DefaultStyles {
DefaultStyles merge(DefaultStyles other) { DefaultStyles merge(DefaultStyles other) {
return DefaultStyles( return DefaultStyles(
h1: other.h1 ?? this.h1, h1: other.h1 ?? h1,
h2: other.h2 ?? this.h2, h2: other.h2 ?? h2,
h3: other.h3 ?? this.h3, h3: other.h3 ?? h3,
paragraph: other.paragraph ?? this.paragraph, paragraph: other.paragraph ?? paragraph,
bold: other.bold ?? this.bold, bold: other.bold ?? bold,
italic: other.italic ?? this.italic, italic: other.italic ?? italic,
underline: other.underline ?? this.underline, underline: other.underline ?? underline,
strikeThrough: other.strikeThrough ?? this.strikeThrough, strikeThrough: other.strikeThrough ?? strikeThrough,
link: other.link ?? this.link, link: other.link ?? link,
placeHolder: other.placeHolder ?? this.placeHolder, placeHolder: other.placeHolder ?? placeHolder,
lists: other.lists ?? this.lists, lists: other.lists ?? lists,
quote: other.quote ?? this.quote, quote: other.quote ?? quote,
code: other.code ?? this.code, code: other.code ?? code,
indent: other.indent ?? this.indent, indent: other.indent ?? indent,
align: other.align ?? this.align, align: other.align ?? align,
sizeSmall: other.sizeSmall ?? this.sizeSmall, sizeSmall: other.sizeSmall ?? sizeSmall,
sizeLarge: other.sizeLarge ?? this.sizeLarge, sizeLarge: other.sizeLarge ?? sizeLarge,
sizeHuge: other.sizeHuge ?? this.sizeHuge); sizeHuge: other.sizeHuge ?? sizeHuge);
} }
} }

@ -28,7 +28,7 @@ class EditorTextSelectionGestureDetectorBuilder {
} }
RenderEditor? getRenderEditor() { RenderEditor? getRenderEditor() {
return this.getEditor()!.getRenderEditor(); return getEditor()!.getRenderEditor();
} }
onTapDown(TapDownDetails details) { onTapDown(TapDownDetails details) {
@ -124,7 +124,7 @@ class EditorTextSelectionGestureDetectorBuilder {
); );
} }
onDragSelectionEnd(DragEndDetails details) {} void onDragSelectionEnd(DragEndDetails details) {}
Widget build(HitTestBehavior behavior, Widget child) { Widget build(HitTestBehavior behavior, Widget child) {
return EditorTextSelectionGestureDetector( return EditorTextSelectionGestureDetector(

@ -11,7 +11,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_quill/models/documents/attribute.dart'; import 'package:flutter_quill/models/documents/attribute.dart';
import 'package:flutter_quill/models/documents/document.dart'; import 'package:flutter_quill/models/documents/document.dart';
import 'package:flutter_quill/models/documents/nodes/container.dart' import 'package:flutter_quill/models/documents/nodes/container.dart'
as containerNode; as container_node;
import 'package:flutter_quill/models/documents/nodes/embed.dart'; import 'package:flutter_quill/models/documents/nodes/embed.dart';
import 'package:flutter_quill/models/documents/nodes/leaf.dart' as leaf; import 'package:flutter_quill/models/documents/nodes/leaf.dart' as leaf;
import 'package:flutter_quill/models/documents/nodes/line.dart'; import 'package:flutter_quill/models/documents/nodes/line.dart';
@ -94,8 +94,8 @@ abstract class RenderAbstractEditor {
} }
String _standardizeImageUrl(String url) { String _standardizeImageUrl(String url) {
if (url.contains("base64")) { if (url.contains('base64')) {
return url.split(",")[1]; return url.split(',')[1];
} }
return url; return url;
} }
@ -211,7 +211,7 @@ class QuillEditor extends StatefulWidget {
class _QuillEditorState extends State<QuillEditor> class _QuillEditorState extends State<QuillEditor>
implements EditorTextSelectionGestureDetectorBuilderDelegate { implements EditorTextSelectionGestureDetectorBuilderDelegate {
GlobalKey<EditorState> _editorKey = GlobalKey<EditorState>(); final GlobalKey<EditorState> _editorKey = GlobalKey<EditorState>();
late EditorTextSelectionGestureDetectorBuilder late EditorTextSelectionGestureDetectorBuilder
_selectionGestureDetectorBuilder; _selectionGestureDetectorBuilder;
@ -382,13 +382,13 @@ class _QuillEditorSelectionGestureDetectorBuilder
} }
TextPosition pos = TextPosition pos =
getRenderEditor()!.getPositionForOffset(details.globalPosition); getRenderEditor()!.getPositionForOffset(details.globalPosition);
containerNode.ChildQuery result = container_node.ChildQuery result =
getEditor()!.widget.controller.document.queryChild(pos.offset); getEditor()!.widget.controller.document.queryChild(pos.offset);
if (result.node == null) { if (result.node == null) {
return false; return false;
} }
Line line = result.node as Line; Line line = result.node as Line;
containerNode.ChildQuery segmentResult = container_node.ChildQuery segmentResult =
line.queryChild(result.offset, false); line.queryChild(result.offset, false);
if (segmentResult.node == null) { if (segmentResult.node == null) {
if (line.length == 1) { if (line.length == 1) {
@ -403,9 +403,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
leaf.Leaf segment = segmentResult.node as leaf.Leaf; leaf.Leaf segment = segmentResult.node as leaf.Leaf;
if (segment.style.containsKey(Attribute.link.key)) { if (segment.style.containsKey(Attribute.link.key)) {
var launchUrl = getEditor()!.widget.onLaunchUrl; var launchUrl = getEditor()!.widget.onLaunchUrl;
if (launchUrl == null) { launchUrl ??= _launchUrl;
launchUrl = _launchUrl;
}
String? link = segment.style.attributes[Attribute.link.key]!.value; String? link = segment.style.attributes[Attribute.link.key]!.value;
if (getEditor()!.widget.readOnly && link != null) { if (getEditor()!.widget.readOnly && link != null) {
link = link.trim(); link = link.trim();
@ -444,7 +442,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
} }
bool _flipListCheckbox( bool _flipListCheckbox(
TextPosition pos, Line line, containerNode.ChildQuery segmentResult) { TextPosition pos, Line line, container_node.ChildQuery segmentResult) {
if (getEditor()!.widget.readOnly || if (getEditor()!.widget.readOnly ||
!line.style.containsKey(Attribute.list.key) || !line.style.containsKey(Attribute.list.key) ||
segmentResult.offset != 0) { segmentResult.offset != 0) {
@ -473,7 +471,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
} }
@override @override
onSingleTapUp(TapUpDetails details) { void onSingleTapUp(TapUpDetails details) {
getEditor()!.hideToolbar(); getEditor()!.hideToolbar();
bool positionSelected = _onTapping(details); bool positionSelected = _onTapping(details);
@ -569,7 +567,7 @@ class RenderEditor extends RenderEditableContainerBox
padding, padding,
); );
setDocument(Document doc) { void setDocument(Document doc) {
if (document == doc) { if (document == doc) {
return; return;
} }
@ -577,7 +575,7 @@ class RenderEditor extends RenderEditableContainerBox
markNeedsLayout(); markNeedsLayout();
} }
setHasFocus(bool h) { void setHasFocus(bool h) {
if (_hasFocus == h) { if (_hasFocus == h) {
return; return;
} }
@ -585,7 +583,7 @@ class RenderEditor extends RenderEditableContainerBox
markNeedsSemanticsUpdate(); markNeedsSemanticsUpdate();
} }
setSelection(TextSelection t) { void setSelection(TextSelection t) {
if (selection == t) { if (selection == t) {
return; return;
} }
@ -593,7 +591,7 @@ class RenderEditor extends RenderEditableContainerBox
markNeedsPaint(); markNeedsPaint();
} }
setStartHandleLayerLink(LayerLink value) { void setStartHandleLayerLink(LayerLink value) {
if (_startHandleLayerLink == value) { if (_startHandleLayerLink == value) {
return; return;
} }
@ -601,7 +599,7 @@ class RenderEditor extends RenderEditableContainerBox
markNeedsPaint(); markNeedsPaint();
} }
setEndHandleLayerLink(LayerLink value) { void setEndHandleLayerLink(LayerLink value) {
if (_endHandleLayerLink == value) { if (_endHandleLayerLink == value) {
return; return;
} }
@ -671,12 +669,12 @@ class RenderEditor extends RenderEditableContainerBox
Offset? _lastTapDownPosition; Offset? _lastTapDownPosition;
@override @override
handleTapDown(TapDownDetails details) { void handleTapDown(TapDownDetails details) {
_lastTapDownPosition = details.globalPosition; _lastTapDownPosition = details.globalPosition;
} }
@override @override
selectWordsInRange( void selectWordsInRange(
Offset from, Offset from,
Offset? to, Offset? to,
SelectionChangedCause cause, SelectionChangedCause cause,
@ -696,7 +694,7 @@ class RenderEditor extends RenderEditableContainerBox
); );
} }
_handleSelectionChange( void _handleSelectionChange(
TextSelection nextSelection, TextSelection nextSelection,
SelectionChangedCause cause, SelectionChangedCause cause,
) { ) {
@ -712,7 +710,7 @@ class RenderEditor extends RenderEditableContainerBox
} }
@override @override
selectWordEdge(SelectionChangedCause cause) { void selectWordEdge(SelectionChangedCause cause) {
assert(_lastTapDownPosition != null); assert(_lastTapDownPosition != null);
TextPosition position = getPositionForOffset(_lastTapDownPosition!); TextPosition position = getPositionForOffset(_lastTapDownPosition!);
RenderEditableBox child = childAtPosition(position); RenderEditableBox child = childAtPosition(position);
@ -742,7 +740,7 @@ class RenderEditor extends RenderEditableContainerBox
} }
@override @override
selectPositionAt( void selectPositionAt(
Offset from, Offset from,
Offset? to, Offset? to,
SelectionChangedCause cause, SelectionChangedCause cause,
@ -766,12 +764,12 @@ class RenderEditor extends RenderEditableContainerBox
} }
@override @override
selectWord(SelectionChangedCause cause) { void selectWord(SelectionChangedCause cause) {
selectWordsInRange(_lastTapDownPosition!, null, cause); selectWordsInRange(_lastTapDownPosition!, null, cause);
} }
@override @override
selectPosition(SelectionChangedCause cause) { void selectPosition(SelectionChangedCause cause) {
selectPositionAt(_lastTapDownPosition!, null, cause); selectPositionAt(_lastTapDownPosition!, null, cause);
} }
@ -821,7 +819,7 @@ class RenderEditor extends RenderEditableContainerBox
return defaultHitTestChildren(result, position: position); return defaultHitTestChildren(result, position: position);
} }
_paintHandleLayers( void _paintHandleLayers(
PaintingContext context, List<TextSelectionPoint> endpoints) { PaintingContext context, List<TextSelectionPoint> endpoints) {
var startPoint = endpoints[0].point; var startPoint = endpoints[0].point;
startPoint = Offset( startPoint = Offset(
@ -904,7 +902,7 @@ class RenderEditableContainerBox extends RenderBox
EditableContainerParentData>, EditableContainerParentData>,
RenderBoxContainerDefaultsMixin<RenderEditableBox, RenderBoxContainerDefaultsMixin<RenderEditableBox,
EditableContainerParentData> { EditableContainerParentData> {
containerNode.Container _container; container_node.Container _container;
TextDirection textDirection; TextDirection textDirection;
EdgeInsetsGeometry _padding; EdgeInsetsGeometry _padding;
EdgeInsets? _resolvedPadding; EdgeInsets? _resolvedPadding;
@ -915,11 +913,11 @@ class RenderEditableContainerBox extends RenderBox
addAll(children); addAll(children);
} }
containerNode.Container getContainer() { container_node.Container getContainer() {
return _container; return _container;
} }
setContainer(containerNode.Container c) { void setContainer(container_node.Container c) {
if (_container == c) { if (_container == c) {
return; return;
} }
@ -929,7 +927,7 @@ class RenderEditableContainerBox extends RenderBox
EdgeInsetsGeometry getPadding() => _padding; EdgeInsetsGeometry getPadding() => _padding;
setPadding(EdgeInsetsGeometry value) { void setPadding(EdgeInsetsGeometry value) {
assert(value.isNonNegative); assert(value.isNonNegative);
if (_padding == value) { if (_padding == value) {
return; return;
@ -940,7 +938,7 @@ class RenderEditableContainerBox extends RenderBox
EdgeInsets? get resolvedPadding => _resolvedPadding; EdgeInsets? get resolvedPadding => _resolvedPadding;
_resolvePadding() { void _resolvePadding() {
if (_resolvedPadding != null) { if (_resolvedPadding != null) {
return; return;
} }
@ -968,7 +966,7 @@ class RenderEditableContainerBox extends RenderBox
return targetChild; return targetChild;
} }
_markNeedsPaddingResolution() { void _markNeedsPaddingResolution() {
_resolvedPadding = null; _resolvedPadding = null;
markNeedsLayout(); markNeedsLayout();
} }
@ -997,7 +995,7 @@ class RenderEditableContainerBox extends RenderBox
} }
@override @override
setupParentData(RenderBox child) { void setupParentData(RenderBox child) {
if (child.parentData is EditableContainerParentData) { if (child.parentData is EditableContainerParentData) {
return; return;
} }

@ -66,7 +66,7 @@ class RenderBaselineProxy extends RenderProxyBox {
// SEE What happens + _padding?.top; // SEE What happens + _padding?.top;
@override @override
performLayout() { void performLayout() {
super.performLayout(); super.performLayout();
_prototypePainter.layout(); _prototypePainter.layout();
} }
@ -289,7 +289,7 @@ class RenderParagraphProxy extends RenderProxyBox
child!.getBoxesForSelection(selection); child!.getBoxesForSelection(selection);
@override @override
performLayout() { void performLayout() {
super.performLayout(); super.performLayout();
_prototypePainter.layout( _prototypePainter.layout(
minWidth: constraints.minWidth, maxWidth: constraints.maxWidth); minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);

@ -100,7 +100,7 @@ class RawEditorState extends EditorState
WidgetsBindingObserver, WidgetsBindingObserver,
TickerProviderStateMixin<RawEditor> TickerProviderStateMixin<RawEditor>
implements TextSelectionDelegate, TextInputClient { implements TextSelectionDelegate, TextInputClient {
GlobalKey _editorKey = GlobalKey(); final GlobalKey _editorKey = GlobalKey();
final List<TextEditingValue> _sentRemoteValues = []; final List<TextEditingValue> _sentRemoteValues = [];
TextInputConnection? _textInputConnection; TextInputConnection? _textInputConnection;
TextEditingValue? _lastKnownRemoteTextEditingValue; TextEditingValue? _lastKnownRemoteTextEditingValue;
@ -144,7 +144,7 @@ class RawEditorState extends EditorState
return result; return result;
} }
handleCursorMovement( void handleCursorMovement(
LogicalKeyboardKey key, LogicalKeyboardKey key,
bool wordModifier, bool wordModifier,
bool lineModifier, bool lineModifier,
@ -370,7 +370,7 @@ class RawEditorState extends EditorState
bool get hasConnection => bool get hasConnection =>
_textInputConnection != null && _textInputConnection!.attached; _textInputConnection != null && _textInputConnection!.attached;
openConnectionIfNeeded() { void openConnectionIfNeeded() {
if (!shouldCreateInputConnection) { if (!shouldCreateInputConnection) {
return; return;
} }
@ -396,7 +396,7 @@ class RawEditorState extends EditorState
_textInputConnection!.show(); _textInputConnection!.show();
} }
closeConnectionIfNeeded() { void closeConnectionIfNeeded() {
if (!hasConnection) { if (!hasConnection) {
return; return;
} }
@ -406,7 +406,7 @@ class RawEditorState extends EditorState
_sentRemoteValues.clear(); _sentRemoteValues.clear();
} }
updateRemoteValueIfNeeded() { void updateRemoteValueIfNeeded() {
if (!hasConnection) { if (!hasConnection) {
return; return;
} }
@ -526,7 +526,6 @@ class RawEditorState extends EditorState
child: Semantics( child: Semantics(
child: _Editor( child: _Editor(
key: _editorKey, key: _editorKey,
children: _buildChildren(_doc, context),
document: _doc, document: _doc,
selection: widget.controller.selection, selection: widget.controller.selection,
hasFocus: _hasFocus, hasFocus: _hasFocus,
@ -535,6 +534,7 @@ class RawEditorState extends EditorState
endHandleLayerLink: _endHandleLayerLink, endHandleLayerLink: _endHandleLayerLink,
onSelectionChanged: _handleSelectionChanged, onSelectionChanged: _handleSelectionChanged,
padding: widget.padding, padding: widget.padding,
children: _buildChildren(_doc, context),
), ),
), ),
); );
@ -571,7 +571,7 @@ class RawEditorState extends EditorState
); );
} }
_handleSelectionChanged( void _handleSelectionChanged(
TextSelection selection, SelectionChangedCause cause) { TextSelection selection, SelectionChangedCause cause) {
widget.controller.updateSelection(selection, ChangeSource.LOCAL); widget.controller.updateSelection(selection, ChangeSource.LOCAL);
@ -582,7 +582,7 @@ class RawEditorState extends EditorState
} }
} }
_buildChildren(Document doc, BuildContext context) { List<Widget> _buildChildren(Document doc, BuildContext context) {
final result = <Widget>[]; final result = <Widget>[];
Map<int, int> indentLevelCounts = {}; Map<int, int> indentLevelCounts = {};
for (Node node in doc.root.children) { for (Node node in doc.root.children) {
@ -717,7 +717,7 @@ class RawEditorState extends EditorState
} }
@override @override
didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
DefaultStyles? parentStyles = QuillStyles.getStyles(context, true); DefaultStyles? parentStyles = QuillStyles.getStyles(context, true);
DefaultStyles defaultStyles = DefaultStyles.getInstance(context); DefaultStyles defaultStyles = DefaultStyles.getInstance(context);
@ -782,7 +782,7 @@ class RawEditorState extends EditorState
!widget.controller.selection.isCollapsed; !widget.controller.selection.isCollapsed;
} }
handleDelete(bool forward) { void handleDelete(bool forward) {
TextSelection selection = widget.controller.selection; TextSelection selection = widget.controller.selection;
String plainText = textEditingValue.text; String plainText = textEditingValue.text;
int cursorPosition = selection.start; int cursorPosition = selection.start;
@ -817,14 +817,14 @@ class RawEditorState extends EditorState
String plainText = textEditingValue.text; String plainText = textEditingValue.text;
if (shortcut == InputShortcut.COPY) { if (shortcut == InputShortcut.COPY) {
if (!selection.isCollapsed) { if (!selection.isCollapsed) {
Clipboard.setData(ClipboardData(text: selection.textInside(plainText))); await Clipboard.setData(ClipboardData(text: selection.textInside(plainText)));
} }
return; return;
} }
if (shortcut == InputShortcut.CUT && !widget.readOnly) { if (shortcut == InputShortcut.CUT && !widget.readOnly) {
if (!selection.isCollapsed) { if (!selection.isCollapsed) {
final data = selection.textInside(plainText); final data = selection.textInside(plainText);
Clipboard.setData(ClipboardData(text: data)); await Clipboard.setData(ClipboardData(text: data));
widget.controller.replaceText( widget.controller.replaceText(
selection.start, selection.start,
@ -881,11 +881,11 @@ class RawEditorState extends EditorState
super.dispose(); super.dispose();
} }
_updateSelectionOverlayForScroll() { void _updateSelectionOverlayForScroll() {
_selectionOverlay?.markNeedsBuild(); _selectionOverlay?.markNeedsBuild();
} }
_didChangeTextEditingValue() { void _didChangeTextEditingValue() {
if (kIsWeb) { if (kIsWeb) {
_onChangeTextEditingValue(); _onChangeTextEditingValue();
requestKeyboard(); requestKeyboard();
@ -899,7 +899,7 @@ class RawEditorState extends EditorState
} }
} }
_onChangeTextEditingValue() { void _onChangeTextEditingValue() {
_showCaretOnScreen(); _showCaretOnScreen();
updateRemoteValueIfNeeded(); updateRemoteValueIfNeeded();
_cursorCont.startOrStopCursorTimerIfNeeded( _cursorCont.startOrStopCursorTimerIfNeeded(
@ -918,7 +918,7 @@ class RawEditorState extends EditorState
}); });
} }
_updateOrDisposeSelectionOverlayIfNeeded() { void _updateOrDisposeSelectionOverlayIfNeeded() {
if (_selectionOverlay != null) { if (_selectionOverlay != null) {
if (_hasFocus) { if (_hasFocus) {
_selectionOverlay!.update(textEditingValue); _selectionOverlay!.update(textEditingValue);
@ -950,7 +950,7 @@ class RawEditorState extends EditorState
} }
} }
_handleFocusChanged() { void _handleFocusChanged() {
openOrCloseConnection(); openOrCloseConnection();
_cursorCont.startOrStopCursorTimerIfNeeded( _cursorCont.startOrStopCursorTimerIfNeeded(
_hasFocus, widget.controller.selection); _hasFocus, widget.controller.selection);
@ -964,7 +964,7 @@ class RawEditorState extends EditorState
updateKeepAlive(); updateKeepAlive();
} }
_onChangedClipboardStatus() { void _onChangedClipboardStatus() {
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
// Inform the widget that the value of clipboardStatus has changed. // Inform the widget that the value of clipboardStatus has changed.
@ -974,7 +974,7 @@ class RawEditorState extends EditorState
bool _showCaretOnScreenScheduled = false; bool _showCaretOnScreenScheduled = false;
_showCaretOnScreen() { void _showCaretOnScreen() {
if (!widget.showCursor || _showCaretOnScreenScheduled) { if (!widget.showCursor || _showCaretOnScreenScheduled) {
return; return;
} }
@ -1039,7 +1039,7 @@ class RawEditorState extends EditorState
bool get selectAllEnabled => widget.toolbarOptions.selectAll; bool get selectAllEnabled => widget.toolbarOptions.selectAll;
@override @override
requestKeyboard() { void requestKeyboard() {
if (_hasFocus) { if (_hasFocus) {
openConnectionIfNeeded(); openConnectionIfNeeded();
} else { } else {
@ -1048,7 +1048,7 @@ class RawEditorState extends EditorState
} }
@override @override
setTextEditingValue(TextEditingValue value) { void setTextEditingValue(TextEditingValue value) {
if (value.text == textEditingValue.text) { if (value.text == textEditingValue.text) {
widget.controller.updateSelection(value.selection, ChangeSource.LOCAL); widget.controller.updateSelection(value.selection, ChangeSource.LOCAL);
} else { } else {
@ -1116,7 +1116,7 @@ class RawEditorState extends EditorState
@override @override
bool get wantKeepAlive => widget.focusNode.hasFocus; bool get wantKeepAlive => widget.focusNode.hasFocus;
openOrCloseConnection() { void openOrCloseConnection() {
if (widget.focusNode.hasFocus && widget.focusNode.consumeKeyboardToken()) { if (widget.focusNode.hasFocus && widget.focusNode.consumeKeyboardToken()) {
openConnectionIfNeeded(); openConnectionIfNeeded();
} else if (!widget.focusNode.hasFocus) { } else if (!widget.focusNode.hasFocus) {
@ -1164,7 +1164,7 @@ class _Editor extends MultiChildRenderObjectWidget {
} }
@override @override
updateRenderObject( void updateRenderObject(
BuildContext context, covariant RenderEditor renderObject) { BuildContext context, covariant RenderEditor renderObject) {
renderObject.document = document; renderObject.document = document;
renderObject.setContainer(document.root); renderObject.setContainer(document.root);

@ -32,19 +32,19 @@ const List<int> arabianRomanNumbers = [
]; ];
const List<String> romanNumbers = [ const List<String> romanNumbers = [
"M", 'M',
"CM", 'CM',
"D", 'D',
"CD", 'CD',
"C", 'C',
"XC", 'XC',
"L", 'L',
"XL", 'XL',
"X", 'X',
"IX", 'IX',
"V", 'V',
"IV", 'IV',
"I" 'I'
]; ];
class EditableTextBlock extends StatelessWidget { class EditableTextBlock extends StatelessWidget {
@ -86,7 +86,7 @@ class EditableTextBlock extends StatelessWidget {
verticalSpacing as Tuple2<double, double>, verticalSpacing as Tuple2<double, double>,
_getDecorationForBlock(block, defaultStyles) ?? BoxDecoration(), _getDecorationForBlock(block, defaultStyles) ?? BoxDecoration(),
contentPadding, contentPadding,
_buildChildren(context, this.indentLevelCounts)); _buildChildren(context, indentLevelCounts));
} }
BoxDecoration? _getDecorationForBlock( BoxDecoration? _getDecorationForBlock(
@ -281,7 +281,7 @@ class RenderEditableTextBlock extends RenderEditableContainerBox
} }
@override @override
setPadding(EdgeInsetsGeometry value) { void setPadding(EdgeInsetsGeometry value) {
super.setPadding(value.add(_contentPadding)); super.setPadding(value.add(_contentPadding));
_savedPadding = value; _savedPadding = value;
} }
@ -478,12 +478,12 @@ class RenderEditableTextBlock extends RenderEditableContainerBox
} }
@override @override
paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
_paintDecoration(context, offset); _paintDecoration(context, offset);
defaultPaint(context, offset); defaultPaint(context, offset);
} }
_paintDecoration(PaintingContext context, Offset offset) { void _paintDecoration(PaintingContext context, Offset offset) {
_painter ??= _decoration.createBoxPainter(markNeedsPaint); _painter ??= _decoration.createBoxPainter(markNeedsPaint);
EdgeInsets decorationPadding = resolvedPadding! - _contentPadding; EdgeInsets decorationPadding = resolvedPadding! - _contentPadding;
@ -571,31 +571,31 @@ class _NumberPoint extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String s = this.index.toString(); String s = index.toString();
int? level = 0; int? level = 0;
if (!this.attrs.containsKey(Attribute.indent.key) && if (!attrs.containsKey(Attribute.indent.key) &&
!this.indentLevelCounts.containsKey(1)) { !indentLevelCounts.containsKey(1)) {
this.indentLevelCounts.clear(); indentLevelCounts.clear();
return Container( return Container(
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
child: Text(withDot ? '$s.' : '$s', style: style),
width: width, width: width,
padding: EdgeInsetsDirectional.only(end: padding), padding: EdgeInsetsDirectional.only(end: padding),
child: Text(withDot ? '$s.' : '$s', style: style),
); );
} }
if (this.attrs.containsKey(Attribute.indent.key)) { if (attrs.containsKey(Attribute.indent.key)) {
level = this.attrs[Attribute.indent.key]!.value; level = attrs[Attribute.indent.key]!.value;
} else { } else {
// first level but is back from previous indent level // first level but is back from previous indent level
// supposed to be "2." // supposed to be "2."
this.indentLevelCounts[0] = 1; indentLevelCounts[0] = 1;
} }
if (this.indentLevelCounts.containsKey(level! + 1)) { if (indentLevelCounts.containsKey(level! + 1)) {
// last visited level is done, going up // last visited level is done, going up
this.indentLevelCounts.remove(level + 1); indentLevelCounts.remove(level + 1);
} }
int count = (this.indentLevelCounts[level] ?? 0) + 1; int count = (indentLevelCounts[level] ?? 0) + 1;
this.indentLevelCounts[level] = count; indentLevelCounts[level] = count;
s = count.toString(); s = count.toString();
if (level % 3 == 1) { if (level % 3 == 1) {
@ -609,9 +609,9 @@ class _NumberPoint extends StatelessWidget {
return Container( return Container(
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
child: Text(withDot ? '$s.' : '$s', style: style),
width: width, width: width,
padding: EdgeInsetsDirectional.only(end: padding), padding: EdgeInsetsDirectional.only(end: padding),
child: Text(withDot ? '$s.' : '$s', style: style),
); );
} }
@ -630,9 +630,9 @@ class _NumberPoint extends StatelessWidget {
var num = input; var num = input;
if (num < 0) { if (num < 0) {
return ""; return '';
} else if (num == 0) { } else if (num == 0) {
return "nulla"; return 'nulla';
} }
final builder = StringBuffer(); final builder = StringBuffer();
@ -665,9 +665,9 @@ class _BulletPoint extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
child: Text('', style: style),
width: width, width: width,
padding: EdgeInsetsDirectional.only(end: 13.0), padding: EdgeInsetsDirectional.only(end: 13.0),
child: Text('', style: style),
); );
} }
} }
@ -706,12 +706,12 @@ class __CheckboxState extends State<_Checkbox> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
alignment: AlignmentDirectional.topEnd, alignment: AlignmentDirectional.topEnd,
width: widget.width,
padding: EdgeInsetsDirectional.only(end: 13.0),
child: Checkbox( child: Checkbox(
value: widget.isChecked, value: widget.isChecked,
onChanged: _onCheckboxClicked, onChanged: _onCheckboxClicked,
), ),
width: widget.width,
padding: EdgeInsetsDirectional.only(end: 13.0),
); );
} }
} }

@ -158,7 +158,7 @@ class TextLine extends StatelessWidget {
if (fontSize != null) { if (fontSize != null) {
res = res.merge(TextStyle(fontSize: fontSize)); res = res.merge(TextStyle(fontSize: fontSize));
} else { } else {
throw "Invalid size ${size.value}"; throw 'Invalid size ${size.value}';
} }
} }
} }
@ -166,13 +166,13 @@ class TextLine extends StatelessWidget {
Attribute? color = textNode.style.attributes[Attribute.color.key]; Attribute? color = textNode.style.attributes[Attribute.color.key];
if (color != null && color.value != null) { if (color != null && color.value != null) {
final textColor = stringToColor(color.value); final textColor = stringToColor(color.value);
res = res.merge(new TextStyle(color: textColor)); res = res.merge(TextStyle(color: textColor));
} }
Attribute? background = textNode.style.attributes[Attribute.background.key]; Attribute? background = textNode.style.attributes[Attribute.background.key];
if (background != null && background.value != null) { if (background != null && background.value != null) {
final backgroundColor = stringToColor(background.value); final backgroundColor = stringToColor(background.value);
res = res.merge(new TextStyle(backgroundColor: backgroundColor)); res = res.merge(TextStyle(backgroundColor: backgroundColor));
} }
return TextSpan(text: textNode.value, style: res); return TextSpan(text: textNode.value, style: res);
@ -235,12 +235,12 @@ class EditableTextLine extends RenderObjectWidget {
hasFocus, hasFocus,
devicePixelRatio, devicePixelRatio,
_getPadding(), _getPadding(),
this.color, color,
cursorCont); cursorCont);
} }
@override @override
updateRenderObject( void updateRenderObject(
BuildContext context, covariant RenderEditableTextLine renderObject) { BuildContext context, covariant RenderEditableTextLine renderObject) {
renderObject.setLine(line); renderObject.setLine(line);
renderObject.setPadding(_getPadding()); renderObject.setPadding(_getPadding());
@ -301,7 +301,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
} }
setCursorCont(CursorCont c) { void setCursorCont(CursorCont c) {
if (cursorCont == c) { if (cursorCont == c) {
return; return;
} }
@ -309,7 +309,7 @@ class RenderEditableTextLine extends RenderEditableBox {
markNeedsLayout(); markNeedsLayout();
} }
setDevicePixelRatio(double d) { void setDevicePixelRatio(double d) {
if (devicePixelRatio == d) { if (devicePixelRatio == d) {
return; return;
} }
@ -317,7 +317,7 @@ class RenderEditableTextLine extends RenderEditableBox {
markNeedsLayout(); markNeedsLayout();
} }
setEnableInteractiveSelection(bool val) { void setEnableInteractiveSelection(bool val) {
if (enableInteractiveSelection == val) { if (enableInteractiveSelection == val) {
return; return;
} }
@ -326,7 +326,7 @@ class RenderEditableTextLine extends RenderEditableBox {
markNeedsSemanticsUpdate(); markNeedsSemanticsUpdate();
} }
setColor(Color c) { void setColor(Color c) {
if (color == c) { if (color == c) {
return; return;
} }
@ -337,7 +337,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
} }
setTextSelection(TextSelection t) { void setTextSelection(TextSelection t) {
if (textSelection == t) { if (textSelection == t) {
return; return;
} }
@ -361,7 +361,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
} }
setTextDirection(TextDirection t) { void setTextDirection(TextDirection t) {
if (textDirection == t) { if (textDirection == t) {
return; return;
} }
@ -370,7 +370,7 @@ class RenderEditableTextLine extends RenderEditableBox {
markNeedsLayout(); markNeedsLayout();
} }
setLine(Line l) { void setLine(Line l) {
if (line == l) { if (line == l) {
return; return;
} }
@ -379,7 +379,7 @@ class RenderEditableTextLine extends RenderEditableBox {
markNeedsLayout(); markNeedsLayout();
} }
setPadding(EdgeInsetsGeometry p) { void setPadding(EdgeInsetsGeometry p) {
assert(p.isNonNegative); assert(p.isNonNegative);
if (padding == p) { if (padding == p) {
return; return;
@ -389,11 +389,11 @@ class RenderEditableTextLine extends RenderEditableBox {
markNeedsLayout(); markNeedsLayout();
} }
setLeading(RenderBox? l) { void setLeading(RenderBox? l) {
_leading = _updateChild(_leading, l, TextLineSlot.LEADING); _leading = _updateChild(_leading, l, TextLineSlot.LEADING);
} }
setBody(RenderContentProxyBox? b) { void setBody(RenderContentProxyBox? b) {
_body = _updateChild(_body, b, TextLineSlot.BODY) as RenderContentProxyBox?; _body = _updateChild(_body, b, TextLineSlot.BODY) as RenderContentProxyBox?;
} }
@ -433,7 +433,7 @@ class RenderEditableTextLine extends RenderEditableBox {
}).toList(growable: false); }).toList(growable: false);
} }
_resolvePadding() { void _resolvePadding() {
if (_resolvedPadding != null) { if (_resolvedPadding != null) {
return; return;
} }
@ -536,7 +536,7 @@ class RenderEditableTextLine extends RenderEditableBox {
double get cursorHeight => double get cursorHeight =>
cursorCont.style.height ?? preferredLineHeight(TextPosition(offset: 0)); cursorCont.style.height ?? preferredLineHeight(TextPosition(offset: 0));
_computeCaretPrototype() { void _computeCaretPrototype() {
switch (defaultTargetPlatform) { switch (defaultTargetPlatform) {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
@ -556,7 +556,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
@override @override
attach(covariant PipelineOwner owner) { void attach(covariant PipelineOwner owner) {
super.attach(owner); super.attach(owner);
for (final child in _children) { for (final child in _children) {
child.attach(owner); child.attach(owner);
@ -568,7 +568,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
@override @override
detach() { void detach() {
super.detach(); super.detach();
for (RenderBox child in _children) { for (RenderBox child in _children) {
child.detach(); child.detach();
@ -580,12 +580,12 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
@override @override
redepthChildren() { void redepthChildren() {
_children.forEach(redepthChild); _children.forEach(redepthChild);
} }
@override @override
visitChildren(RenderObjectVisitor visitor) { void visitChildren(RenderObjectVisitor visitor) {
_children.forEach(visitor); _children.forEach(visitor);
} }
@ -722,7 +722,7 @@ class RenderEditableTextLine extends RenderEditableBox {
); );
@override @override
paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
if (_leading != null) { if (_leading != null) {
final parentData = _leading!.parentData as BoxParentData; final parentData = _leading!.parentData as BoxParentData;
final effectiveOffset = offset + parentData.offset; final effectiveOffset = offset + parentData.offset;
@ -760,7 +760,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
} }
_paintSelection(PaintingContext context, Offset effectiveOffset) { void _paintSelection(PaintingContext context, Offset effectiveOffset) {
assert(_selectedRects != null); assert(_selectedRects != null);
final paint = Paint()..color = color; final paint = Paint()..color = color;
for (final box in _selectedRects!) { for (final box in _selectedRects!) {
@ -768,7 +768,7 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
} }
_paintCursor(PaintingContext context, Offset effectiveOffset) { void _paintCursor(PaintingContext context, Offset effectiveOffset) {
final position = TextPosition( final position = TextPosition(
offset: textSelection.extentOffset - line.getDocumentOffset(), offset: textSelection.extentOffset - line.getDocumentOffset(),
affinity: textSelection.base.affinity, affinity: textSelection.base.affinity,
@ -778,7 +778,7 @@ class RenderEditableTextLine extends RenderEditableBox {
@override @override
bool hitTestChildren(BoxHitTestResult result, {required Offset position}) { bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
return this._children.first.hitTest(result, position: position); return _children.first.hitTest(result, position: position);
} }
} }
@ -795,12 +795,12 @@ class _TextLineElement extends RenderObjectElement {
super.renderObject as RenderEditableTextLine; super.renderObject as RenderEditableTextLine;
@override @override
visitChildren(ElementVisitor visitor) { void visitChildren(ElementVisitor visitor) {
_slotToChildren.values.forEach(visitor); _slotToChildren.values.forEach(visitor);
} }
@override @override
forgetChild(Element child) { void forgetChild(Element child) {
assert(_slotToChildren.containsValue(child)); assert(_slotToChildren.containsValue(child));
assert(child.slot is TextLineSlot); assert(child.slot is TextLineSlot);
assert(_slotToChildren.containsKey(child.slot)); assert(_slotToChildren.containsKey(child.slot));
@ -809,14 +809,14 @@ class _TextLineElement extends RenderObjectElement {
} }
@override @override
mount(Element? parent, dynamic newSlot) { void mount(Element? parent, dynamic newSlot) {
super.mount(parent, newSlot); super.mount(parent, newSlot);
_mountChild(widget.leading, TextLineSlot.LEADING); _mountChild(widget.leading, TextLineSlot.LEADING);
_mountChild(widget.body, TextLineSlot.BODY); _mountChild(widget.body, TextLineSlot.BODY);
} }
@override @override
update(EditableTextLine newWidget) { void update(EditableTextLine newWidget) {
super.update(newWidget); super.update(newWidget);
assert(widget == newWidget); assert(widget == newWidget);
_updateChild(widget.leading, TextLineSlot.LEADING); _updateChild(widget.leading, TextLineSlot.LEADING);
@ -824,14 +824,14 @@ class _TextLineElement extends RenderObjectElement {
} }
@override @override
insertRenderObjectChild(RenderBox child, TextLineSlot? slot) { void insertRenderObjectChild(RenderBox child, TextLineSlot? slot) {
// assert(child is RenderBox); // assert(child is RenderBox);
_updateRenderObject(child, slot); _updateRenderObject(child, slot);
assert(renderObject.children.keys.contains(slot)); assert(renderObject.children.keys.contains(slot));
} }
@override @override
removeRenderObjectChild(RenderObject child, TextLineSlot? slot) { void removeRenderObjectChild(RenderObject child, TextLineSlot? slot) {
assert(child is RenderBox); assert(child is RenderBox);
assert(renderObject.children[slot!] == child); assert(renderObject.children[slot!] == child);
_updateRenderObject(null, slot); _updateRenderObject(null, slot);
@ -839,7 +839,7 @@ class _TextLineElement extends RenderObjectElement {
} }
@override @override
moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) { void moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) {
throw UnimplementedError(); throw UnimplementedError();
} }

@ -1,5 +1,5 @@
name: flutter_quill name: flutter_quill
description: Rich text editor (Demo App https://bulletjournal.us/home/index.html ). description: A rich text editor.
version: 1.1.2 version: 1.1.2
#author: bulletjournal #author: bulletjournal
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html

Loading…
Cancel
Save