From 27d9ac3bdd09169a37a5748b6ac1dad46c66b2f3 Mon Sep 17 00:00:00 2001 From: Benjamin Quinn Date: Mon, 10 Oct 2022 14:08:18 -0400 Subject: [PATCH] Make QuillController.document mutable. (#973) --- lib/src/widgets/controller.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/src/widgets/controller.dart b/lib/src/widgets/controller.dart index db6637a5..e6b32180 100644 --- a/lib/src/widgets/controller.dart +++ b/lib/src/widgets/controller.dart @@ -17,14 +17,15 @@ typedef DeleteCallback = void Function(int cursorPosition, bool forward); class QuillController extends ChangeNotifier { QuillController({ - required this.document, + required Document document, required TextSelection selection, bool keepStyleOnNewLine = false, this.onReplaceText, this.onDelete, this.onSelectionCompleted, this.onSelectionChanged, - }) : _selection = selection, + }) : _document = document, + _selection = selection, _keepStyleOnNewLine = keepStyleOnNewLine; factory QuillController.basic() { @@ -35,7 +36,12 @@ class QuillController extends ChangeNotifier { } /// Document managed by this controller. - final Document document; + Document _document; + Document get document => _document; + set document(doc) { + _document = doc; + notifyListeners(); + } /// Tells whether to keep or reset the [toggledStyle] /// when user adds a new line.