From 5249ad3c4c026eeae964953e9dfd56c51ffe9520 Mon Sep 17 00:00:00 2001 From: Douglas Ward Date: Sun, 21 Apr 2024 18:49:30 -0600 Subject: [PATCH] Removed deprecated functions --- lib/src/widgets/quill/quill_controller.dart | 43 ------------------- .../toolbar/buttons/font_family_button.dart | 6 --- .../toolbar/buttons/font_size_button.dart | 6 --- .../toolbar/buttons/toggle_style_button.dart | 36 +++++++++++----- 4 files changed, 26 insertions(+), 65 deletions(-) diff --git a/lib/src/widgets/quill/quill_controller.dart b/lib/src/widgets/quill/quill_controller.dart index 9338e2c6..1a2634e4 100644 --- a/lib/src/widgets/quill/quill_controller.dart +++ b/lib/src/widgets/quill/quill_controller.dart @@ -66,49 +66,6 @@ class QuillController extends ChangeNotifier { notifyListeners(); } - // Those are the values that the user selects and not the one - // from the current line - - /// The current font family, null to use the default one - @Deprecated('No longer used') - MapEntry? _selectedFontFamily; - - /// The current font family, null to use the default one - @Deprecated('No longer used') - MapEntry? get selectedFontFamily => _selectedFontFamily; - - @Deprecated('No longer used') - void selectFontFamily(MapEntry? newFontFamily) { - _selectedFontFamily = newFontFamily; - } - - /// The current font size, null to use the default one - @Deprecated('No longer used') - MapEntry? _selectedFontSize; - - /// The current font size, null to use the default one - @Deprecated('No longer used') - MapEntry? get selectedFontSize => _selectedFontSize; - - @Deprecated('No longer used') - void selectFontSize(MapEntry? newFontSize) { - _selectedFontSize = newFontSize; - } - - /// For the [QuillToolbarToggleStyleButton] - @Deprecated('No longer used') - final Map _selectedStyles = {}; - - /// For the [QuillToolbarToggleStyleButton] - @Deprecated('No longer used') - Map get selectedStyles => _selectedStyles; - - /// For the [QuillToolbarToggleStyleButton] - @Deprecated('No longer used') - void selectStyle(Attribute attribute, bool value) { - _selectedStyles[attribute] = value; - } - /// Tells whether to keep or reset the [toggledStyle] /// when user adds a new line. final bool keepStyleOnNewLine; diff --git a/lib/src/widgets/toolbar/buttons/font_family_button.dart b/lib/src/widgets/toolbar/buttons/font_family_button.dart index ca112964..10cf8712 100644 --- a/lib/src/widgets/toolbar/buttons/font_family_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_family_button.dart @@ -147,12 +147,6 @@ class QuillToolbarFontFamilyButtonState options.onSelected?.call(newValue); } }); - - if (fontFamily.value == 'Clear') { - controller.selectFontFamily(null); - return; - } - controller.selectFontFamily(fontFamily); }, child: Text( fontFamily.key.toString(), diff --git a/lib/src/widgets/toolbar/buttons/font_size_button.dart b/lib/src/widgets/toolbar/buttons/font_size_button.dart index 0612c82e..71a6bfcc 100644 --- a/lib/src/widgets/toolbar/buttons/font_size_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_size_button.dart @@ -136,12 +136,6 @@ class QuillToolbarFontSizeButtonState extends QuillToolbarBaseValueButtonState< options.onSelected?.call(newValue); } }); - - if (fontSize.value == '0') { - controller.selectFontSize(null); - return; - } - controller.selectFontSize(fontSize); }, child: Text( fontSize.key.toString(), diff --git a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart index 76b74b94..32db56ec 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart @@ -21,7 +21,9 @@ typedef ToggleStyleButtonBuilder = Widget Function( QuillIconTheme? iconTheme, ]); -class QuillToolbarToggleStyleButton extends QuillToolbarBaseValueButton { +class QuillToolbarToggleStyleButton extends QuillToolbarBaseValueButton< + QuillToolbarToggleStyleButtonOptions, + QuillToolbarToggleStyleButtonExtraOptions> { const QuillToolbarToggleStyleButton({ required super.controller, required this.attribute, @@ -32,11 +34,16 @@ class QuillToolbarToggleStyleButton extends QuillToolbarBaseValueButton QuillToolbarToggleStyleButtonState(); + QuillToolbarToggleStyleButtonState createState() => + QuillToolbarToggleStyleButtonState(); } class QuillToolbarToggleStyleButtonState - extends QuillToolbarBaseValueButtonState { + extends QuillToolbarBaseValueButtonState< + QuillToolbarToggleStyleButton, + QuillToolbarToggleStyleButtonOptions, + QuillToolbarToggleStyleButtonExtraOptions, + bool> { Style get _selectionStyle => controller.getSelectionStyle(); @override @@ -77,7 +84,10 @@ class QuillToolbarToggleStyleButtonState 'left' => (context.loc.alignLeft, Icons.format_align_left), 'right' => (context.loc.alignRight, Icons.format_align_right), 'center' => (context.loc.alignCenter, Icons.format_align_center), - 'justify' => (context.loc.justifyWinWidth, Icons.format_align_justify), + 'justify' => ( + context.loc.justifyWinWidth, + Icons.format_align_justify + ), Object() => throw ArgumentError(widget.attribute.value), null => (context.loc.alignCenter, Icons.format_align_center), }; @@ -93,7 +103,9 @@ class QuillToolbarToggleStyleButtonState String get defaultTooltip => _defaultTooltipAndIconData.$1; IconData get iconData { - return options.iconData ?? context.quillToolbarBaseButtonOptions?.iconData ?? _defaultTooltipAndIconData.$2; + return options.iconData ?? + context.quillToolbarBaseButtonOptions?.iconData ?? + _defaultTooltipAndIconData.$2; } void _onPressed() { @@ -103,7 +115,8 @@ class QuillToolbarToggleStyleButtonState @override Widget build(BuildContext context) { - final childBuilder = options.childBuilder ?? context.quillToolbarBaseButtonOptions?.childBuilder; + final childBuilder = options.childBuilder ?? + context.quillToolbarBaseButtonOptions?.childBuilder; if (childBuilder != null) { return childBuilder( options, @@ -133,7 +146,9 @@ class QuillToolbarToggleStyleButtonState } bool _getIsToggled(Map attrs) { - if (widget.attribute.key == Attribute.list.key || widget.attribute.key == Attribute.script.key || widget.attribute.key == Attribute.align.key) { + if (widget.attribute.key == Attribute.list.key || + widget.attribute.key == Attribute.script.key || + widget.attribute.key == Attribute.align.key) { final attribute = attrs[widget.attribute.key]; if (attribute == null) { return false; @@ -147,9 +162,10 @@ class QuillToolbarToggleStyleButtonState controller ..skipRequestKeyboard = !widget.attribute.isInline ..formatSelection( - currentValue ? Attribute.clone(widget.attribute, null) : widget.attribute, - ) - ..selectStyle(widget.attribute, currentValue); + currentValue + ? Attribute.clone(widget.attribute, null) + : widget.attribute, + ); } }