From 38299176abea74b8ae3087393fea640db5074bcc Mon Sep 17 00:00:00 2001 From: ritheshSalyan Date: Fri, 19 Feb 2021 23:16:58 +0530 Subject: [PATCH] support for custom non-styling attribute --- .vscode/launch.json | 15 +++++++++++++++ lib/models/documents/attribute.dart | 3 ++- lib/models/documents/style.dart | 2 +- lib/widgets/toolbar.dart | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..f9c59272 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "flutter-quill", + "request": "launch", + "type": "dart", + "program": "app/lib/main.dart" + }, + + ] +} \ No newline at end of file diff --git a/lib/models/documents/attribute.dart b/lib/models/documents/attribute.dart index 5f55e035..ec9ca9d8 100644 --- a/lib/models/documents/attribute.dart +++ b/lib/models/documents/attribute.dart @@ -155,7 +155,8 @@ class Attribute { static Attribute fromKeyValue(String key, dynamic value) { if (!_registry.containsKey(key)) { - throw ArgumentError.value(key, 'key "$key" not found.'); + return null; + // throw ArgumentError.value(key, 'key "$key" not found.'); } Attribute origin = _registry[key]; Attribute attribute = clone(origin, value); diff --git a/lib/models/documents/style.dart b/lib/models/documents/style.dart index cd05cd03..68825790 100644 --- a/lib/models/documents/style.dart +++ b/lib/models/documents/style.dart @@ -17,7 +17,7 @@ class Style { Map result = attributes.map((String key, dynamic value) { Attribute attr = Attribute.fromKeyValue(key, value); - return MapEntry(key, attr); + return MapEntry(key, attr??Attribute(key, AttributeScope.INLINE, value)); }); return Style.attr(result); } diff --git a/lib/widgets/toolbar.dart b/lib/widgets/toolbar.dart index 69de725a..d7b4ab78 100644 --- a/lib/widgets/toolbar.dart +++ b/lib/widgets/toolbar.dart @@ -742,6 +742,7 @@ class _HistoryButtonState extends State { } void _setIconColor() { + if(!mounted) return; if (widget.undo) { setState(() { _iconColor = widget.controller.hasUndo