Move Controller outside of configurations data class (#2078)

pull/2082/head v10.1.3
AtlasAutocode 8 months ago committed by GitHub
parent 4d6380f028
commit 23fbb43b76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      README.md
  2. 2
      doc/attribute_introduction.md
  3. 1
      doc/configurations/custom_buttons.md
  4. 6
      doc/custom_embed_blocks.md
  5. 4
      doc/translation.md
  6. 3
      example/lib/screens/quill/my_quill_editor.dart
  7. 6
      example/lib/screens/quill/my_quill_toolbar.dart
  8. 3
      example/lib/screens/quill/quill_screen.dart
  9. 10
      example/lib/screens/simple/simple_screen.dart
  10. 4
      lib/src/controller/provider.dart
  11. 18
      lib/src/controller/quill_controller.dart
  12. 12
      lib/src/controller/quill_controller_configurations.dart
  13. 14
      lib/src/editor/config/editor_configurations.dart
  14. 105
      lib/src/editor/editor.dart
  15. 26
      lib/src/editor/provider.dart
  16. 7
      lib/src/editor/raw_editor/config/raw_editor_configurations.dart
  17. 10
      lib/src/editor/raw_editor/raw_editor.dart
  18. 13
      lib/src/editor/raw_editor/raw_editor_state.dart
  19. 9
      lib/src/editor/raw_editor/raw_editor_state_selection_delegate_mixin.dart
  20. 5
      lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart
  21. 5
      lib/src/toolbar/base_toolbar.dart
  22. 7
      lib/src/toolbar/config/simple_toolbar_configurations.dart
  23. 105
      lib/src/toolbar/simple_toolbar.dart
  24. 14
      test/bug_fix_test.dart
  25. 15
      test/editor/editor_test.dart

@ -130,16 +130,18 @@ Instantiate a controller:
QuillController _controller = QuillController.basic(); QuillController _controller = QuillController.basic();
``` ```
Use the `QuillEditor`, and `QuillToolbar` widgets, Use the `QuillEditor`, and `QuillSimpleToolbar` widgets,
and attach the `QuillController` to them: and attach the `QuillController` to them:
```dart ```dart
QuillToolbar.simple( QuillSimpleToolbar(
configurations: QuillSimpleToolbarConfigurations(controller: _controller), controller: _controller,
configurations: QuillSimpleToolbarConfigurations(),
), ),
Expanded( Expanded(
child: QuillEditor.basic( child: QuillEditor.basic(
configurations: QuillEditorConfigurations(controller: _controller), controller: _controller,
configurations: const QuillEditorConfigurations(),
), ),
) )
``` ```

@ -85,8 +85,8 @@ On `QuillEditor` or `QuillEditorConfigurations` **doesn't exist** a param that l
##### The editor ##### The editor
```dart ```dart
QuillEditor.basic( QuillEditor.basic(
controller: controller,
configurations: QuillEditorConfigurations( configurations: QuillEditorConfigurations(
controller: controller,
customStyleBuilder: (Attribute<dynamic> attribute) { customStyleBuilder: (Attribute<dynamic> attribute) {
if (attribute.key.equals(highlightKey)) { if (attribute.key.equals(highlightKey)) {
return TextStyle(color: Colors.black, backgroundColor: Colors.yellow); return TextStyle(color: Colors.black, backgroundColor: Colors.yellow);

@ -22,6 +22,7 @@ Each `QuillCustomButton` is used as part of the `customButtons` option as follow
```dart ```dart
QuillToolbar.simple( QuillToolbar.simple(
controller: _controller,
configurations: QuillSimpleToolbarConfigurations( configurations: QuillSimpleToolbarConfigurations(
customButtons: [ customButtons: [
QuillToolbarCustomButtonOptions( QuillToolbarCustomButtonOptions(

@ -98,10 +98,8 @@ Future<void> _addEditNote(BuildContext context, {Document? document}) async {
], ],
), ),
content: QuillEditor.basic( content: QuillEditor.basic(
configurations: const QuillEditorConfigurations( controller: quillEditorController,
controller: quillEditorController, configurations: const QuillEditorConfigurations(),
readOnly: false,
),
), ),
), ),
); );

@ -6,8 +6,8 @@ with:
```dart ```dart
QuillToolbar.simple( QuillToolbar.simple(
controller: _controller,
configurations: QuillSimpleToolbarConfigurations( configurations: QuillSimpleToolbarConfigurations(
controller: _controller,
sharedConfigurations: const QuillSharedConfigurations( sharedConfigurations: const QuillSharedConfigurations(
locale: Locale('de'), locale: Locale('de'),
), ),
@ -15,8 +15,8 @@ QuillToolbar.simple(
), ),
Expanded( Expanded(
child: QuillEditor.basic( child: QuillEditor.basic(
controller: _controller,
configurations: QuillEditorConfigurations( configurations: QuillEditorConfigurations(
controller: _controller,
sharedConfigurations: const QuillSharedConfigurations( sharedConfigurations: const QuillSharedConfigurations(
locale: Locale('de'), locale: Locale('de'),
), ),

@ -18,12 +18,14 @@ import 'embeds/timestamp_embed.dart';
class MyQuillEditor extends StatelessWidget { class MyQuillEditor extends StatelessWidget {
const MyQuillEditor({ const MyQuillEditor({
required this.controller,
required this.configurations, required this.configurations,
required this.scrollController, required this.scrollController,
required this.focusNode, required this.focusNode,
super.key, super.key,
}); });
final QuillController controller;
final QuillEditorConfigurations configurations; final QuillEditorConfigurations configurations;
final ScrollController scrollController; final ScrollController scrollController;
final FocusNode focusNode; final FocusNode focusNode;
@ -34,6 +36,7 @@ class MyQuillEditor extends StatelessWidget {
return QuillEditor( return QuillEditor(
scrollController: scrollController, scrollController: scrollController,
focusNode: focusNode, focusNode: focusNode,
controller: controller,
configurations: configurations.copyWith( configurations: configurations.copyWith(
elementOptions: const QuillEditorElementOptions( elementOptions: const QuillEditorElementOptions(
codeBlock: QuillEditorCodeBlockElementOptions( codeBlock: QuillEditorCodeBlockElementOptions(

@ -203,8 +203,12 @@ class MyQuillToolbar extends StatelessWidget {
); );
} }
return QuillToolbar.simple( return QuillToolbar.simple(
controller: controller,
/// configurations parameter:
/// Optional: if not provided will use the configuration set when the controller was instantiated.
/// Override: Provide parameter here to override the default configuration - useful if configuration will change.
configurations: QuillSimpleToolbarConfigurations( configurations: QuillSimpleToolbarConfigurations(
controller: controller,
showAlignmentButtons: true, showAlignmentButtons: true,
multiRowsDisplay: true, multiRowsDisplay: true,
fontFamilyValues: { fontFamilyValues: {

@ -33,6 +33,7 @@ class QuillScreen extends StatefulWidget {
} }
class _QuillScreenState extends State<QuillScreen> { class _QuillScreenState extends State<QuillScreen> {
/// Instantiate the controller
final _controller = QuillController.basic(); final _controller = QuillController.basic();
final _editorFocusNode = FocusNode(); final _editorFocusNode = FocusNode();
final _editorScrollController = ScrollController(); final _editorScrollController = ScrollController();
@ -101,9 +102,9 @@ class _QuillScreenState extends State<QuillScreen> {
builder: (context) { builder: (context) {
return Expanded( return Expanded(
child: MyQuillEditor( child: MyQuillEditor(
controller: _controller,
configurations: QuillEditorConfigurations( configurations: QuillEditorConfigurations(
sharedConfigurations: _sharedConfigurations, sharedConfigurations: _sharedConfigurations,
controller: _controller,
), ),
scrollController: _editorScrollController, scrollController: _editorScrollController,
focusNode: _editorFocusNode, focusNode: _editorFocusNode,

@ -18,14 +18,14 @@ class _SimpleScreenState extends State<SimpleScreen> {
body: Column( body: Column(
children: [ children: [
QuillToolbar.simple( QuillToolbar.simple(
configurations: controller: _controller,
QuillSimpleToolbarConfigurations(controller: _controller), configurations: const QuillSimpleToolbarConfigurations(),
), ),
Expanded( Expanded(
child: QuillEditor.basic( child: QuillEditor.basic(
configurations: QuillEditorConfigurations( controller: _controller,
controller: _controller, configurations: const QuillEditorConfigurations(
padding: const EdgeInsets.all(16), padding: EdgeInsets.all(16),
), ),
), ),
), ),

@ -6,12 +6,16 @@ import 'quill_controller.dart';
extension QuillControllerExt on BuildContext { extension QuillControllerExt on BuildContext {
QuillController? get quilController { QuillController? get quilController {
// ignore: deprecated_member_use_from_same_package
return quillSimpleToolbarConfigurations?.controller ?? return quillSimpleToolbarConfigurations?.controller ??
// ignore: deprecated_member_use_from_same_package
quillEditorConfigurations?.controller; quillEditorConfigurations?.controller;
} }
QuillController get requireQuillController { QuillController get requireQuillController {
// ignore: deprecated_member_use_from_same_package
return quillSimpleToolbarConfigurations?.controller ?? return quillSimpleToolbarConfigurations?.controller ??
// ignore: deprecated_member_use_from_same_package
quillEditorConfigurations?.controller ?? quillEditorConfigurations?.controller ??
(throw ArgumentError( (throw ArgumentError(
'The quill provider is required, you must only call requireQuillController inside the QuillToolbar and QuillEditor')); 'The quill provider is required, you must only call requireQuillController inside the QuillToolbar and QuillEditor'));

@ -19,6 +19,7 @@ import '../document/structs/doc_change.dart';
import '../document/style.dart'; import '../document/style.dart';
import '../editor/config/editor_configurations.dart'; import '../editor/config/editor_configurations.dart';
import '../editor_toolbar_controller_shared/clipboard/clipboard_service_provider.dart'; import '../editor_toolbar_controller_shared/clipboard/clipboard_service_provider.dart';
import '../toolbar/config/simple_toolbar_configurations.dart';
import 'quill_controller_configurations.dart'; import 'quill_controller_configurations.dart';
typedef ReplaceTextCallback = bool Function(int index, int len, Object? data); typedef ReplaceTextCallback = bool Function(int index, int len, Object? data);
@ -52,13 +53,24 @@ class QuillController extends ChangeNotifier {
final QuillControllerConfigurations configurations; final QuillControllerConfigurations configurations;
/// Local copy of editor configurations enables fail-safe setting from editor _initState method /// Editor configurations
///
/// Caches configuration set in QuillEditor ctor.
QuillEditorConfigurations? _editorConfigurations; QuillEditorConfigurations? _editorConfigurations;
QuillEditorConfigurations? get editorConfigurations => QuillEditorConfigurations get editorConfigurations =>
configurations.editorConfigurations ?? _editorConfigurations; _editorConfigurations ?? const QuillEditorConfigurations();
set editorConfigurations(QuillEditorConfigurations? value) => set editorConfigurations(QuillEditorConfigurations? value) =>
_editorConfigurations = value; _editorConfigurations = value;
/// Toolbar configurations
///
/// Caches configuration set in QuillSimpleToolbar ctor.
QuillSimpleToolbarConfigurations? _toolbarConfigurations;
QuillSimpleToolbarConfigurations get toolbarConfigurations =>
_toolbarConfigurations ?? const QuillSimpleToolbarConfigurations();
set toolbarConfigurations(QuillSimpleToolbarConfigurations? value) =>
_toolbarConfigurations = value;
/// Document managed by this controller. /// Document managed by this controller.
Document _document; Document _document;

@ -1,14 +1,16 @@
import '../editor/config/editor_configurations.dart'; import '../editor/config/editor_configurations.dart'
show QuillEditorConfigurations;
class QuillControllerConfigurations { class QuillControllerConfigurations {
const QuillControllerConfigurations( const QuillControllerConfigurations(
{this.editorConfigurations, {@Deprecated(
'This parameter is not used and will be removed in future versions.')
this.editorConfigurations,
this.onClipboardPaste, this.onClipboardPaste,
this.requireScriptFontFeatures = false}); this.requireScriptFontFeatures = false});
/// Provides central access to editor configurations required for controller actions @Deprecated(
/// 'This parameter is not used and will be removed in future versions.')
/// Future: will be changed to 'required final'
final QuillEditorConfigurations? editorConfigurations; final QuillEditorConfigurations? editorConfigurations;
/// Callback when the user pastes and data has not already been processed /// Callback when the user pastes and data has not already been processed

@ -24,7 +24,9 @@ class QuillEditorConfigurations extends Equatable {
/// Important note for the maintainers /// Important note for the maintainers
/// When editing this class please update the [copyWith] function too. /// When editing this class please update the [copyWith] function too.
const QuillEditorConfigurations({ const QuillEditorConfigurations({
required this.controller, @Deprecated(
'controller should be passed directly to the editor - this parameter will be removed in future versions.')
this.controller,
this.sharedConfigurations = const QuillSharedConfigurations(), this.sharedConfigurations = const QuillSharedConfigurations(),
this.scrollable = true, this.scrollable = true,
this.padding = EdgeInsets.zero, this.padding = EdgeInsets.zero,
@ -86,7 +88,8 @@ class QuillEditorConfigurations extends Equatable {
final QuillSharedConfigurations sharedConfigurations; final QuillSharedConfigurations sharedConfigurations;
final QuillController controller; @Deprecated('controller will be removed in future versions.')
final QuillController? controller;
/// The text placeholder in the quill editor /// The text placeholder in the quill editor
final String? placeholder; final String? placeholder;
@ -97,7 +100,8 @@ class QuillEditorConfigurations extends Equatable {
/// by any shortcut or keyboard operation. The text is still selectable. /// by any shortcut or keyboard operation. The text is still selectable.
/// ///
/// Defaults to `false`. Must not be `null`. /// Defaults to `false`. Must not be `null`.
bool get readOnly => controller.readOnly; // ignore: deprecated_member_use_from_same_package
bool get readOnly => controller?.readOnly != false;
/// Override [readOnly] for checkbox. /// Override [readOnly] for checkbox.
/// ///
@ -381,7 +385,8 @@ class QuillEditorConfigurations extends Equatable {
@override @override
List<Object?> get props => [ List<Object?> get props => [
placeholder, placeholder,
controller.readOnly, // ignore: deprecated_member_use_from_same_package
controller?.readOnly,
]; ];
// We might use code generator like freezed but sometimes it can be limited // We might use code generator like freezed but sometimes it can be limited
@ -445,6 +450,7 @@ class QuillEditorConfigurations extends Equatable {
}) { }) {
return QuillEditorConfigurations( return QuillEditorConfigurations(
sharedConfigurations: sharedConfigurations ?? this.sharedConfigurations, sharedConfigurations: sharedConfigurations ?? this.sharedConfigurations,
// ignore: deprecated_member_use_from_same_package
controller: controller ?? this.controller, controller: controller ?? this.controller,
placeholder: placeholder ?? this.placeholder, placeholder: placeholder ?? this.placeholder,
checkBoxReadOnly: checkBoxReadOnly ?? this.checkBoxReadOnly, checkBoxReadOnly: checkBoxReadOnly ?? this.checkBoxReadOnly,

@ -10,6 +10,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import '../common/utils/platform.dart'; import '../common/utils/platform.dart';
import '../controller/quill_controller.dart';
import '../document/attribute.dart'; import '../document/attribute.dart';
import '../document/document.dart'; import '../document/document.dart';
import '../document/nodes/container.dart' as container_node; import '../document/nodes/container.dart' as container_node;
@ -120,36 +121,80 @@ abstract class RenderAbstractEditor implements TextLayoutMetrics {
} }
class QuillEditor extends StatefulWidget { class QuillEditor extends StatefulWidget {
const QuillEditor({ /// Quick start guide:
required this.configurations, ///
required this.focusNode, /// Instantiate a controller:
required this.scrollController, /// QuillController _controller = QuillController.basic();
super.key, ///
}); /// Connect the controller to the `QuillEditor` and `QuillSimpleToolbar` widgets.
/// QuillSimpleToolbar(
/// controller: _controller,
/// configurations: const QuillSimpleToolbarConfigurations(),
/// ),
/// Expanded(
/// child: QuillEditor.basic(
/// controller: _controller,
/// configurations: const QuillEditorConfigurations(),
/// ),
/// ),
///
factory QuillEditor({
required FocusNode focusNode,
required ScrollController scrollController,
/// Controller and configurations are required
///
/// Prefer: use controller and pass QuillEditorConfigurations in constructor for controller (using QuillControllerConfigurations).
/// Backward compatibility: use configurations and pass QuillController in constructor for configurations. (Will be removed in future versions.)
QuillController? controller,
QuillEditorConfigurations? configurations,
}) {
// ignore: deprecated_member_use_from_same_package
controller ??= configurations?.controller;
assert(controller != null,
'controller required. Provide controller directly (preferred) or indirectly through configurations (not recommended - will be removed in future versions).');
controller ??= QuillController(
document: Document(),
selection: const TextSelection.collapsed(offset: 0));
//
controller
..editorConfigurations = configurations
..editorFocusNode = focusNode;
//
return QuillEditor._(
focusNode: focusNode,
scrollController: scrollController,
controller: controller);
}
const QuillEditor._(
{required this.focusNode,
required this.scrollController,
required this.controller});
factory QuillEditor.basic({ factory QuillEditor.basic({
/// The controller for the quill editor widget of flutter quill
QuillController? controller,
/// The configurations for the quill editor widget of flutter quill /// The configurations for the quill editor widget of flutter quill
required QuillEditorConfigurations configurations, QuillEditorConfigurations? configurations,
FocusNode? focusNode, FocusNode? focusNode,
ScrollController? scrollController, ScrollController? scrollController,
}) { }) {
return QuillEditor( return QuillEditor(
scrollController: scrollController ?? ScrollController(), scrollController: scrollController ?? ScrollController(),
focusNode: focusNode ?? FocusNode(), focusNode: focusNode ?? FocusNode(),
configurations: configurations.copyWith( controller: controller,
textSelectionThemeData: configurations.textSelectionThemeData, configurations: configurations?.copyWith(),
autoFocus: configurations.autoFocus,
expands: configurations.expands,
padding: configurations.padding,
keyboardAppearance: configurations.keyboardAppearance,
embedBuilders: configurations.embedBuilders,
editorKey: configurations.editorKey,
),
); );
} }
/// The controller for the quill editor widget of flutter quill
final QuillController controller;
/// The configurations for the quill editor widget of flutter quill /// The configurations for the quill editor widget of flutter quill
final QuillEditorConfigurations configurations; QuillEditorConfigurations get configurations =>
controller.editorConfigurations;
/// Controls whether this editor has keyboard focus. /// Controls whether this editor has keyboard focus.
final FocusNode focusNode; final FocusNode focusNode;
@ -167,9 +212,9 @@ class QuillEditorState extends State<QuillEditor>
late EditorTextSelectionGestureDetectorBuilder late EditorTextSelectionGestureDetectorBuilder
_selectionGestureDetectorBuilder; _selectionGestureDetectorBuilder;
QuillEditorConfigurations get configurations { QuillController get controller => widget.controller;
return widget.configurations;
} QuillEditorConfigurations get configurations => widget.configurations;
@override @override
void initState() { void initState() {
@ -181,11 +226,7 @@ class QuillEditorState extends State<QuillEditor>
configurations.detectWordBoundary, configurations.detectWordBoundary,
); );
widget.configurations.controller.editorConfigurations ??= final focusNode = widget.focusNode;
widget.configurations;
final focusNode =
widget.configurations.controller.editorFocusNode ??= widget.focusNode;
if (configurations.autoFocus) { if (configurations.autoFocus) {
focusNode.requestFocus(); focusNode.requestFocus();
@ -241,13 +282,13 @@ class QuillEditorState extends State<QuillEditor>
final child = FlutterQuillLocalizationsWidget( final child = FlutterQuillLocalizationsWidget(
child: QuillEditorProvider( child: QuillEditorProvider(
editorConfigurations: configurations, controller: controller,
child: QuillEditorBuilderWidget( child: QuillEditorBuilderWidget(
builder: configurations.builder, builder: configurations.builder,
child: QuillRawEditor( child: QuillRawEditor(
key: _editorKey, key: _editorKey,
controller: controller,
configurations: QuillRawEditorConfigurations( configurations: QuillRawEditorConfigurations(
controller: configurations.controller,
focusNode: widget.focusNode, focusNode: widget.focusNode,
scrollController: widget.scrollController, scrollController: widget.scrollController,
scrollable: configurations.scrollable, scrollable: configurations.scrollable,
@ -255,7 +296,7 @@ class QuillEditorState extends State<QuillEditor>
configurations.enableMarkdownStyleConversion, configurations.enableMarkdownStyleConversion,
scrollBottomInset: configurations.scrollBottomInset, scrollBottomInset: configurations.scrollBottomInset,
padding: configurations.padding, padding: configurations.padding,
readOnly: configurations.readOnly, readOnly: controller.readOnly,
checkBoxReadOnly: configurations.checkBoxReadOnly, checkBoxReadOnly: configurations.checkBoxReadOnly,
disableClipboard: configurations.disableClipboard, disableClipboard: configurations.disableClipboard,
placeholder: configurations.placeholder, placeholder: configurations.placeholder,
@ -445,19 +486,19 @@ class _QuillEditorSelectionGestureDetectorBuilder
} }
bool _isPositionSelected(TapUpDetails details) { bool _isPositionSelected(TapUpDetails details) {
if (_state.configurations.controller.document.isEmpty()) { if (_state.controller.document.isEmpty()) {
return false; return false;
} }
final pos = renderEditor!.getPositionForOffset(details.globalPosition); final pos = renderEditor!.getPositionForOffset(details.globalPosition);
final result = editor!.widget.configurations.controller.document final result =
.querySegmentLeafNode(pos.offset); editor!.widget.controller.document.querySegmentLeafNode(pos.offset);
final line = result.line; final line = result.line;
if (line == null) { if (line == null) {
return false; return false;
} }
final segmentLeaf = result.leaf; final segmentLeaf = result.leaf;
if (segmentLeaf == null && line.length == 1) { if (segmentLeaf == null && line.length == 1) {
editor!.widget.configurations.controller.updateSelection( editor!.widget.controller.updateSelection(
TextSelection.collapsed(offset: pos.offset), TextSelection.collapsed(offset: pos.offset),
ChangeSource.local, ChangeSource.local,
); );

@ -2,15 +2,32 @@ import 'package:flutter/foundation.dart' show debugPrint, kDebugMode;
import 'package:flutter/widgets.dart' import 'package:flutter/widgets.dart'
show BuildContext, InheritedWidget, Widget; show BuildContext, InheritedWidget, Widget;
import '../controller/quill_controller.dart';
import 'config/editor_configurations.dart'; import 'config/editor_configurations.dart';
class QuillEditorProvider extends InheritedWidget { class QuillEditorProvider extends InheritedWidget {
const QuillEditorProvider({ QuillEditorProvider({
required super.child, required super.child,
required this.editorConfigurations,
/// Controller and configurations are required but should only be provided from one.
///
/// Passing the controller as part of configurations is being deprecated and will be removed in the future.
/// Prefer: use controller and set QuillEditorConfigurations in the controller.
/// Current: use configurations and pass QuillController in constructor for configurations.
QuillController? controller,
@Deprecated(
'editorConfigurations are no longer needed and will be removed in future versions. Set configurations in the controller')
QuillEditorConfigurations? editorConfigurations,
super.key, super.key,
}); }) : editorConfigurations = editorConfigurations ??
controller?.editorConfigurations ??
const QuillEditorConfigurations(),
controller = controller ??
// ignore: deprecated_member_use_from_same_package
editorConfigurations?.controller ??
QuillController.basic();
final QuillController controller;
final QuillEditorConfigurations editorConfigurations; final QuillEditorConfigurations editorConfigurations;
@override @override
@ -52,8 +69,9 @@ class QuillEditorProvider extends InheritedWidget {
required QuillEditorProvider value, required QuillEditorProvider value,
required Widget child, required Widget child,
}) { }) {
value.controller.editorConfigurations = value.editorConfigurations;
return QuillEditorProvider( return QuillEditorProvider(
editorConfigurations: value.editorConfigurations, controller: value.controller,
child: child, child: child,
); );
} }

@ -40,7 +40,6 @@ import '../../../toolbar/theme/quill_dialog_theme.dart';
@immutable @immutable
class QuillRawEditorConfigurations extends Equatable { class QuillRawEditorConfigurations extends Equatable {
const QuillRawEditorConfigurations({ const QuillRawEditorConfigurations({
required this.controller,
required this.focusNode, required this.focusNode,
required this.scrollController, required this.scrollController,
required this.scrollBottomInset, required this.scrollBottomInset,
@ -49,6 +48,9 @@ class QuillRawEditorConfigurations extends Equatable {
required this.selectionCtrls, required this.selectionCtrls,
required this.embedBuilder, required this.embedBuilder,
required this.autoFocus, required this.autoFocus,
@Deprecated(
'controller should be passed directly to the editor - this parameter will be removed in future versions.')
this.controller,
this.showCursor = true, this.showCursor = true,
this.scrollable = true, this.scrollable = true,
this.padding = EdgeInsets.zero, this.padding = EdgeInsets.zero,
@ -93,7 +95,8 @@ class QuillRawEditorConfigurations extends Equatable {
}); });
/// Controls the document being edited. /// Controls the document being edited.
final QuillController controller; @Deprecated('controller will be removed in future versions.')
final QuillController? controller;
/// Controls whether this editor has keyboard focus. /// Controls whether this editor has keyboard focus.
final FocusNode focusNode; final FocusNode focusNode;

@ -12,6 +12,7 @@ import 'package:flutter/widgets.dart'
immutable; immutable;
import '../../common/structs/offset_value.dart'; import '../../common/structs/offset_value.dart';
import '../../controller/quill_controller.dart';
import '../editor.dart'; import '../editor.dart';
import '../widgets/text/text_selection.dart'; import '../widgets/text/text_selection.dart';
import 'config/raw_editor_configurations.dart'; import 'config/raw_editor_configurations.dart';
@ -20,8 +21,14 @@ import 'raw_editor_state.dart';
class QuillRawEditor extends StatefulWidget { class QuillRawEditor extends StatefulWidget {
QuillRawEditor({ QuillRawEditor({
required this.configurations, required this.configurations,
controller,
super.key, super.key,
}) : assert( }) :
// ignore: deprecated_member_use_from_same_package
assert((controller ?? configurations.controller) != null),
// ignore: deprecated_member_use_from_same_package
controller = controller ?? configurations.controller,
assert(
configurations.maxHeight == null || configurations.maxHeight! > 0, configurations.maxHeight == null || configurations.maxHeight! > 0,
'maxHeight cannot be null'), 'maxHeight cannot be null'),
assert( assert(
@ -33,6 +40,7 @@ class QuillRawEditor extends StatefulWidget {
configurations.maxHeight! >= configurations.minHeight!, configurations.maxHeight! >= configurations.minHeight!,
'maxHeight cannot be null'); 'maxHeight cannot be null');
final QuillController controller;
final QuillRawEditorConfigurations configurations; final QuillRawEditorConfigurations configurations;
@override @override

@ -77,7 +77,7 @@ class QuillRawEditorState extends EditorState
// Cursors // Cursors
late CursorCont _cursorCont; late CursorCont _cursorCont;
QuillController get controller => widget.configurations.controller; QuillController get controller => widget.controller;
// Focus // Focus
bool _didAutoFocus = false; bool _didAutoFocus = false;
@ -1274,9 +1274,8 @@ class QuillRawEditorState extends EditorState
_cursorCont.show.value = widget.configurations.showCursor; _cursorCont.show.value = widget.configurations.showCursor;
_cursorCont.style = widget.configurations.cursorStyle; _cursorCont.style = widget.configurations.cursorStyle;
if (controller != oldWidget.configurations.controller) { if (controller != oldWidget.controller) {
oldWidget.configurations.controller oldWidget.controller.removeListener(_didChangeTextEditingValue);
.removeListener(_didChangeTextEditingValue);
controller.addListener(_didChangeTextEditingValue); controller.addListener(_didChangeTextEditingValue);
updateRemoteValueIfNeeded(); updateRemoteValueIfNeeded();
} }
@ -1293,7 +1292,7 @@ class QuillRawEditorState extends EditorState
updateKeepAlive(); updateKeepAlive();
} }
if (controller.selection != oldWidget.configurations.controller.selection) { if (controller.selection != oldWidget.controller.selection) {
_selectionOverlay?.update(textEditingValue); _selectionOverlay?.update(textEditingValue);
} }
@ -1348,7 +1347,7 @@ class QuillRawEditorState extends EditorState
/// operating on stale data. /// operating on stale data.
void _markNeedsBuild() { void _markNeedsBuild() {
if (_dirty) { if (_dirty) {
// No need to rebuilt if it already darty // No need to rebuilt if it already dirty
return; return;
} }
setState(() { setState(() {
@ -1626,7 +1625,7 @@ class QuillRawEditorState extends EditorState
final QuillEditorTextBoundary boundary; final QuillEditorTextBoundary boundary;
// final TextEditingValue textEditingValue = // final TextEditingValue textEditingValue =
// _textEditingValueforTextLayoutMetrics; // _textEditingValueForTextLayoutMetrics;
atomicTextBoundary = QuillEditorCharacterBoundary(textEditingValue); atomicTextBoundary = QuillEditorCharacterBoundary(textEditingValue);
// This isn't enough. Newline characters. // This isn't enough. Newline characters.
boundary = QuillEditorExpandedTextBoundary( boundary = QuillEditorExpandedTextBoundary(

@ -11,22 +11,21 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState
implements TextSelectionDelegate { implements TextSelectionDelegate {
@override @override
TextEditingValue get textEditingValue { TextEditingValue get textEditingValue {
return widget.configurations.controller.plainTextEditingValue; return widget.controller.plainTextEditingValue;
} }
set textEditingValue(TextEditingValue value) { set textEditingValue(TextEditingValue value) {
final cursorPosition = value.selection.extentOffset; final cursorPosition = value.selection.extentOffset;
final oldText = widget.configurations.controller.document.toPlainText(); final oldText = widget.controller.document.toPlainText();
final newText = value.text; final newText = value.text;
final diff = getDiff(oldText, newText, cursorPosition); final diff = getDiff(oldText, newText, cursorPosition);
if (diff.deleted == '' && diff.inserted == '') { if (diff.deleted == '' && diff.inserted == '') {
// Only changing selection range // Only changing selection range
widget.configurations.controller widget.controller.updateSelection(value.selection, ChangeSource.local);
.updateSelection(value.selection, ChangeSource.local);
return; return;
} }
widget.configurations.controller.replaceTextWithEmbeds( widget.controller.replaceTextWithEmbeds(
diff.start, diff.deleted.length, diff.inserted, value.selection); diff.start, diff.deleted.length, diff.inserted, value.selection);
} }

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

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../../flutter_quill.dart' import '../../flutter_quill.dart'
show QuillToolbarProvider, kDefaultToolbarSize; show QuillToolbarProvider, kDefaultToolbarSize;
import '../controller/quill_controller.dart';
import '../l10n/widgets/localizations.dart'; import '../l10n/widgets/localizations.dart';
import 'config/simple_toolbar_configurations.dart'; import 'config/simple_toolbar_configurations.dart';
import 'config/toolbar_configurations.dart'; import 'config/toolbar_configurations.dart';
@ -40,8 +41,10 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
}); });
static QuillSimpleToolbar simple( static QuillSimpleToolbar simple(
{required QuillSimpleToolbarConfigurations configurations}) { {QuillController? controller,
QuillSimpleToolbarConfigurations? configurations}) {
return QuillSimpleToolbar( return QuillSimpleToolbar(
controller: controller,
configurations: configurations, configurations: configurations,
); );
} }

@ -80,7 +80,9 @@ enum SearchButtonType {
@immutable @immutable
class QuillSimpleToolbarConfigurations extends QuillSharedToolbarProperties { class QuillSimpleToolbarConfigurations extends QuillSharedToolbarProperties {
const QuillSimpleToolbarConfigurations({ const QuillSimpleToolbarConfigurations({
required this.controller, @Deprecated(
'controller should be passed directly to the toolbar - this parameter will be removed in future versions.')
this.controller,
super.sharedConfigurations, super.sharedConfigurations,
super.toolbarSectionSpacing = kToolbarSectionSpacing, super.toolbarSectionSpacing = kToolbarSectionSpacing,
super.toolbarIconAlignment = WrapAlignment.center, super.toolbarIconAlignment = WrapAlignment.center,
@ -166,7 +168,8 @@ class QuillSimpleToolbarConfigurations extends QuillSharedToolbarProperties {
final Map<String, String>? fontFamilyValues; final Map<String, String>? fontFamilyValues;
final QuillController controller; @Deprecated('controller will be removed in future versions.')
final QuillController? controller;
/// By default it will be /// By default it will be
/// ```dart /// ```dart

@ -1,6 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../controller/quill_controller.dart';
import '../document/attribute.dart'; import '../document/attribute.dart';
import '../document/document.dart';
import 'base_toolbar.dart'; import 'base_toolbar.dart';
import 'buttons/alignment/select_alignment_buttons.dart'; import 'buttons/alignment/select_alignment_buttons.dart';
import 'buttons/arrow_indicated_list_button.dart'; import 'buttons/arrow_indicated_list_button.dart';
@ -9,13 +11,37 @@ import 'simple_toolbar_provider.dart';
class QuillSimpleToolbar extends StatelessWidget class QuillSimpleToolbar extends StatelessWidget
implements PreferredSizeWidget { implements PreferredSizeWidget {
const QuillSimpleToolbar({ factory QuillSimpleToolbar({
required this.configurations, required QuillSimpleToolbarConfigurations? configurations,
QuillController? controller,
Key? key,
}) {
// ignore: deprecated_member_use_from_same_package
controller ??= configurations?.controller;
assert(controller != null,
'controller required. Provide controller directly (preferred) or indirectly through configurations (not recommended - will be removed in future versions).');
controller ??= QuillController(
document: Document(),
selection: const TextSelection.collapsed(offset: 0));
//
controller.toolbarConfigurations = configurations;
//
return QuillSimpleToolbar._(
controller: controller,
key: key,
);
}
const QuillSimpleToolbar._({
required this.controller,
super.key, super.key,
}); });
final QuillController controller;
/// The configurations for the toolbar widget of flutter quill /// The configurations for the toolbar widget of flutter quill
final QuillSimpleToolbarConfigurations configurations; QuillSimpleToolbarConfigurations get configurations =>
controller.toolbarConfigurations;
double get _toolbarSize => configurations.toolbarSize * 1.4; double get _toolbarSize => configurations.toolbarSize * 1.4;
@ -30,7 +56,6 @@ class QuillSimpleToolbar extends StatelessWidget
final globalIconSize = toolbarConfigurations.buttonOptions.base.iconSize; final globalIconSize = toolbarConfigurations.buttonOptions.base.iconSize;
final axis = toolbarConfigurations.axis; final axis = toolbarConfigurations.axis;
final globalController = configurations.controller;
final divider = SizedBox( final divider = SizedBox(
height: _toolbarSize, height: _toolbarSize,
@ -46,93 +71,93 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarHistoryButton( QuillToolbarHistoryButton(
isUndo: true, isUndo: true,
options: toolbarConfigurations.buttonOptions.undoHistory, options: toolbarConfigurations.buttonOptions.undoHistory,
controller: globalController, controller: controller,
), ),
if (configurations.showRedo) if (configurations.showRedo)
QuillToolbarHistoryButton( QuillToolbarHistoryButton(
isUndo: false, isUndo: false,
options: toolbarConfigurations.buttonOptions.redoHistory, options: toolbarConfigurations.buttonOptions.redoHistory,
controller: globalController, controller: controller,
), ),
if (configurations.showFontFamily) if (configurations.showFontFamily)
QuillToolbarFontFamilyButton( QuillToolbarFontFamilyButton(
options: toolbarConfigurations.buttonOptions.fontFamily, options: toolbarConfigurations.buttonOptions.fontFamily,
controller: globalController, controller: controller,
), ),
if (configurations.showFontSize) if (configurations.showFontSize)
QuillToolbarFontSizeButton( QuillToolbarFontSizeButton(
options: toolbarConfigurations.buttonOptions.fontSize, options: toolbarConfigurations.buttonOptions.fontSize,
controller: globalController, controller: controller,
), ),
if (configurations.showBoldButton) if (configurations.showBoldButton)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.bold, attribute: Attribute.bold,
options: toolbarConfigurations.buttonOptions.bold, options: toolbarConfigurations.buttonOptions.bold,
controller: globalController, controller: controller,
), ),
if (configurations.showItalicButton) if (configurations.showItalicButton)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.italic, attribute: Attribute.italic,
options: toolbarConfigurations.buttonOptions.italic, options: toolbarConfigurations.buttonOptions.italic,
controller: globalController, controller: controller,
), ),
if (configurations.showUnderLineButton) if (configurations.showUnderLineButton)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.underline, attribute: Attribute.underline,
options: toolbarConfigurations.buttonOptions.underLine, options: toolbarConfigurations.buttonOptions.underLine,
controller: globalController, controller: controller,
), ),
if (configurations.showStrikeThrough) if (configurations.showStrikeThrough)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.strikeThrough, attribute: Attribute.strikeThrough,
options: toolbarConfigurations.buttonOptions.strikeThrough, options: toolbarConfigurations.buttonOptions.strikeThrough,
controller: globalController, controller: controller,
), ),
if (configurations.showInlineCode) if (configurations.showInlineCode)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.inlineCode, attribute: Attribute.inlineCode,
options: toolbarConfigurations.buttonOptions.inlineCode, options: toolbarConfigurations.buttonOptions.inlineCode,
controller: globalController, controller: controller,
), ),
if (configurations.showSubscript) if (configurations.showSubscript)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.subscript, attribute: Attribute.subscript,
options: toolbarConfigurations.buttonOptions.subscript, options: toolbarConfigurations.buttonOptions.subscript,
controller: globalController, controller: controller,
), ),
if (configurations.showSuperscript) if (configurations.showSuperscript)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.superscript, attribute: Attribute.superscript,
options: toolbarConfigurations.buttonOptions.superscript, options: toolbarConfigurations.buttonOptions.superscript,
controller: globalController, controller: controller,
), ),
if (configurations.showSmallButton) if (configurations.showSmallButton)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.small, attribute: Attribute.small,
options: toolbarConfigurations.buttonOptions.small, options: toolbarConfigurations.buttonOptions.small,
controller: globalController, controller: controller,
), ),
if (configurations.showColorButton) if (configurations.showColorButton)
QuillToolbarColorButton( QuillToolbarColorButton(
controller: globalController, controller: controller,
isBackground: false, isBackground: false,
options: toolbarConfigurations.buttonOptions.color, options: toolbarConfigurations.buttonOptions.color,
), ),
if (configurations.showBackgroundColorButton) if (configurations.showBackgroundColorButton)
QuillToolbarColorButton( QuillToolbarColorButton(
options: toolbarConfigurations.buttonOptions.backgroundColor, options: toolbarConfigurations.buttonOptions.backgroundColor,
controller: globalController, controller: controller,
isBackground: true, isBackground: true,
), ),
if (configurations.showClearFormat) if (configurations.showClearFormat)
QuillToolbarClearFormatButton( QuillToolbarClearFormatButton(
controller: globalController, controller: controller,
options: toolbarConfigurations.buttonOptions.clearFormat, options: toolbarConfigurations.buttonOptions.clearFormat,
), ),
if (theEmbedButtons != null) if (theEmbedButtons != null)
for (final builder in theEmbedButtons) for (final builder in theEmbedButtons)
builder( builder(
globalController, controller,
globalIconSize ?? kDefaultIconSize, globalIconSize ?? kDefaultIconSize,
context.quillToolbarBaseButtonOptions?.iconTheme, context.quillToolbarBaseButtonOptions?.iconTheme,
configurations.dialogTheme), configurations.dialogTheme),
@ -140,7 +165,7 @@ class QuillSimpleToolbar extends StatelessWidget
[ [
if (configurations.showAlignmentButtons) if (configurations.showAlignmentButtons)
QuillToolbarSelectAlignmentButtons( QuillToolbarSelectAlignmentButtons(
controller: globalController, controller: controller,
options: toolbarConfigurations options: toolbarConfigurations
.buttonOptions.selectAlignmentButtons .buttonOptions.selectAlignmentButtons
.copyWith( .copyWith(
@ -154,26 +179,26 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.rtl, attribute: Attribute.rtl,
options: toolbarConfigurations.buttonOptions.direction, options: toolbarConfigurations.buttonOptions.direction,
controller: globalController, controller: controller,
), ),
], ],
[ [
if (configurations.showLineHeightButton) if (configurations.showLineHeightButton)
QuillToolbarSelectLineHeightStyleDropdownButton( QuillToolbarSelectLineHeightStyleDropdownButton(
controller: globalController, controller: controller,
options: toolbarConfigurations options: toolbarConfigurations
.buttonOptions.selectLineHeightStyleDropdownButton, .buttonOptions.selectLineHeightStyleDropdownButton,
), ),
if (configurations.showHeaderStyle) ...[ if (configurations.showHeaderStyle) ...[
if (configurations.headerStyleType.isOriginal) if (configurations.headerStyleType.isOriginal)
QuillToolbarSelectHeaderStyleDropdownButton( QuillToolbarSelectHeaderStyleDropdownButton(
controller: globalController, controller: controller,
options: toolbarConfigurations options: toolbarConfigurations
.buttonOptions.selectHeaderStyleDropdownButton, .buttonOptions.selectHeaderStyleDropdownButton,
) )
else else
QuillToolbarSelectHeaderStyleButtons( QuillToolbarSelectHeaderStyleButtons(
controller: globalController, controller: controller,
options: toolbarConfigurations options: toolbarConfigurations
.buttonOptions.selectHeaderStyleButtons, .buttonOptions.selectHeaderStyleButtons,
), ),
@ -184,42 +209,42 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.ol, attribute: Attribute.ol,
options: toolbarConfigurations.buttonOptions.listNumbers, options: toolbarConfigurations.buttonOptions.listNumbers,
controller: globalController, controller: controller,
), ),
if (configurations.showListBullets) if (configurations.showListBullets)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.ul, attribute: Attribute.ul,
options: toolbarConfigurations.buttonOptions.listBullets, options: toolbarConfigurations.buttonOptions.listBullets,
controller: globalController, controller: controller,
), ),
if (configurations.showListCheck) if (configurations.showListCheck)
QuillToolbarToggleCheckListButton( QuillToolbarToggleCheckListButton(
options: toolbarConfigurations.buttonOptions.toggleCheckList, options: toolbarConfigurations.buttonOptions.toggleCheckList,
controller: globalController, controller: controller,
), ),
if (configurations.showCodeBlock) if (configurations.showCodeBlock)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.codeBlock, attribute: Attribute.codeBlock,
options: toolbarConfigurations.buttonOptions.codeBlock, options: toolbarConfigurations.buttonOptions.codeBlock,
controller: globalController, controller: controller,
), ),
], ],
[ [
if (configurations.showQuote) if (configurations.showQuote)
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
options: toolbarConfigurations.buttonOptions.quote, options: toolbarConfigurations.buttonOptions.quote,
controller: globalController, controller: controller,
attribute: Attribute.blockQuote, attribute: Attribute.blockQuote,
), ),
if (configurations.showIndent) if (configurations.showIndent)
QuillToolbarIndentButton( QuillToolbarIndentButton(
controller: globalController, controller: controller,
isIncrease: true, isIncrease: true,
options: toolbarConfigurations.buttonOptions.indentIncrease, options: toolbarConfigurations.buttonOptions.indentIncrease,
), ),
if (configurations.showIndent) if (configurations.showIndent)
QuillToolbarIndentButton( QuillToolbarIndentButton(
controller: globalController, controller: controller,
isIncrease: false, isIncrease: false,
options: toolbarConfigurations.buttonOptions.indentDecrease, options: toolbarConfigurations.buttonOptions.indentDecrease,
), ),
@ -228,40 +253,40 @@ class QuillSimpleToolbar extends StatelessWidget
if (configurations.showLink) if (configurations.showLink)
toolbarConfigurations.linkStyleType.isOriginal toolbarConfigurations.linkStyleType.isOriginal
? QuillToolbarLinkStyleButton( ? QuillToolbarLinkStyleButton(
controller: globalController, controller: controller,
options: toolbarConfigurations.buttonOptions.linkStyle, options: toolbarConfigurations.buttonOptions.linkStyle,
) )
: QuillToolbarLinkStyleButton2( : QuillToolbarLinkStyleButton2(
controller: globalController, controller: controller,
options: toolbarConfigurations.buttonOptions.linkStyle2, options: toolbarConfigurations.buttonOptions.linkStyle2,
), ),
if (configurations.showSearchButton) if (configurations.showSearchButton)
switch (configurations.searchButtonType) { switch (configurations.searchButtonType) {
SearchButtonType.legacy => QuillToolbarLegacySearchButton( SearchButtonType.legacy => QuillToolbarLegacySearchButton(
controller: globalController, controller: controller,
options: toolbarConfigurations.buttonOptions.search, options: toolbarConfigurations.buttonOptions.search,
), ),
SearchButtonType.modern => QuillToolbarSearchButton( SearchButtonType.modern => QuillToolbarSearchButton(
controller: globalController, controller: controller,
options: toolbarConfigurations.buttonOptions.search, options: toolbarConfigurations.buttonOptions.search,
), ),
}, },
if (configurations.showClipboardCut) if (configurations.showClipboardCut)
QuillToolbarClipboardButton( QuillToolbarClipboardButton(
options: toolbarConfigurations.buttonOptions.clipboardCut, options: toolbarConfigurations.buttonOptions.clipboardCut,
controller: globalController, controller: controller,
clipboardAction: ClipboardAction.cut, clipboardAction: ClipboardAction.cut,
), ),
if (configurations.showClipboardCopy) if (configurations.showClipboardCopy)
QuillToolbarClipboardButton( QuillToolbarClipboardButton(
options: toolbarConfigurations.buttonOptions.clipboardCopy, options: toolbarConfigurations.buttonOptions.clipboardCopy,
controller: globalController, controller: controller,
clipboardAction: ClipboardAction.copy, clipboardAction: ClipboardAction.copy,
), ),
if (configurations.showClipboardPaste) if (configurations.showClipboardPaste)
QuillToolbarClipboardButton( QuillToolbarClipboardButton(
options: toolbarConfigurations.buttonOptions.clipboardPaste, options: toolbarConfigurations.buttonOptions.clipboardPaste,
controller: globalController, controller: controller,
clipboardAction: ClipboardAction.paste, clipboardAction: ClipboardAction.paste,
), ),
], ],
@ -269,7 +294,7 @@ class QuillSimpleToolbar extends StatelessWidget
for (final customButton in configurations.customButtons) for (final customButton in configurations.customButtons)
QuillToolbarCustomButton( QuillToolbarCustomButton(
options: customButton, options: customButton,
controller: globalController, controller: controller,
), ),
], ],
]; ];

@ -19,10 +19,10 @@ void main() {
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
body: QuillSimpleToolbar( body: QuillSimpleToolbar(
configurations: QuillSimpleToolbarConfigurations( controller: controller,
controller: controller, configurations: const QuillSimpleToolbarConfigurations(
showRedo: false, showRedo: false,
customButtons: const [ customButtons: [
QuillToolbarCustomButtonOptions( QuillToolbarCustomButtonOptions(
tooltip: tooltip, tooltip: tooltip,
) )
@ -56,9 +56,7 @@ void main() {
setUp(() { setUp(() {
controller = QuillController.basic(); controller = QuillController.basic();
editor = QuillEditor.basic( editor = QuillEditor.basic(
configurations: QuillEditorConfigurations( controller: controller,
controller: controller,
),
); );
}); });
@ -142,8 +140,8 @@ void main() {
home: QuillEditor( home: QuillEditor(
focusNode: FocusNode(), focusNode: FocusNode(),
scrollController: ScrollController(), scrollController: ScrollController(),
configurations: QuillEditorConfigurations( controller: controller,
controller: controller, configurations: const QuillEditorConfigurations(
autoFocus: true, autoFocus: true,
expands: true, expands: true,
), ),

@ -24,11 +24,11 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: QuillEditor.basic( home: QuillEditor.basic(
controller: controller,
// ignore: avoid_redundant_argument_values // ignore: avoid_redundant_argument_values
configurations: QuillEditorConfigurations( configurations: const QuillEditorConfigurations(
controller: controller, // ignore: avoid_redundant_argument_values
// ignore: avoid_redundant_argument_values ),
),
), ),
), ),
); );
@ -44,8 +44,8 @@ void main() {
home: QuillEditor( home: QuillEditor(
focusNode: FocusNode(), focusNode: FocusNode(),
scrollController: ScrollController(), scrollController: ScrollController(),
controller: controller,
configurations: QuillEditorConfigurations( configurations: QuillEditorConfigurations(
controller: controller,
// ignore: avoid_redundant_argument_values // ignore: avoid_redundant_argument_values
autoFocus: true, autoFocus: true,
expands: true, expands: true,
@ -116,9 +116,9 @@ void main() {
home: QuillEditor( home: QuillEditor(
focusNode: FocusNode(), focusNode: FocusNode(),
scrollController: ScrollController(), scrollController: ScrollController(),
controller: controller,
// ignore: avoid_redundant_argument_values // ignore: avoid_redundant_argument_values
configurations: QuillEditorConfigurations( configurations: QuillEditorConfigurations(
controller: controller,
// ignore: avoid_redundant_argument_values // ignore: avoid_redundant_argument_values
autoFocus: true, autoFocus: true,
expands: true, expands: true,
@ -146,7 +146,8 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: QuillEditor.basic( home: QuillEditor.basic(
configurations: QuillEditorConfigurations(controller: controller), controller: controller,
configurations: const QuillEditorConfigurations(),
focusNode: editorFocusNode, focusNode: editorFocusNode,
), ),
), ),

Loading…
Cancel
Save