From 57f81efab64d2fbe0c8322c19aecb4fbff589cd0 Mon Sep 17 00:00:00 2001 From: X Code Date: Sun, 30 Jan 2022 23:33:40 -0800 Subject: [PATCH] Update check list button --- lib/src/widgets/raw_editor.dart | 1 + .../widgets/toolbar/toggle_check_list_button.dart | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/src/widgets/raw_editor.dart b/lib/src/widgets/raw_editor.dart index c2df6395..e7f7ff5c 100644 --- a/lib/src/widgets/raw_editor.dart +++ b/lib/src/widgets/raw_editor.dart @@ -764,6 +764,7 @@ class RawEditorState extends EditorState // https://github.com/singerdmx/flutter-quill/issues/619 // We cannot treat {"list": "checked"} and {"list": "unchecked"} as // block of the same style + // This causes controller.selection to go to offset 0 bool _disableScrollControllerAnimateOnce = false; void _showCaretOnScreen() { diff --git a/lib/src/widgets/toolbar/toggle_check_list_button.dart b/lib/src/widgets/toolbar/toggle_check_list_button.dart index ed24a84d..cf52ff00 100644 --- a/lib/src/widgets/toolbar/toggle_check_list_button.dart +++ b/lib/src/widgets/toolbar/toggle_check_list_button.dart @@ -55,15 +55,13 @@ class _ToggleCheckListButtonState extends State { } bool _getIsToggled(Map attrs) { - if (widget.attribute.key == Attribute.list.key) { - final attribute = attrs[widget.attribute.key]; - if (attribute == null) { - return false; - } - return attribute.value == widget.attribute.value || - attribute.value == Attribute.checked.value; + final attribute = attrs[Attribute.list.key]; + + if (attribute == null) { + return false; } - return attrs.containsKey(widget.attribute.key); + return attribute.value == Attribute.unchecked.value || + attribute.value == Attribute.checked.value; } @override