Removed deprecated functions

pull/1829/head
Douglas Ward 1 year ago
parent b79379633c
commit 5249ad3c4c
  1. 43
      lib/src/widgets/quill/quill_controller.dart
  2. 6
      lib/src/widgets/toolbar/buttons/font_family_button.dart
  3. 6
      lib/src/widgets/toolbar/buttons/font_size_button.dart
  4. 36
      lib/src/widgets/toolbar/buttons/toggle_style_button.dart

@ -66,49 +66,6 @@ class QuillController extends ChangeNotifier {
notifyListeners(); 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<String, String>? _selectedFontFamily;
/// The current font family, null to use the default one
@Deprecated('No longer used')
MapEntry<String, String>? get selectedFontFamily => _selectedFontFamily;
@Deprecated('No longer used')
void selectFontFamily(MapEntry<String, String>? newFontFamily) {
_selectedFontFamily = newFontFamily;
}
/// The current font size, null to use the default one
@Deprecated('No longer used')
MapEntry<String, String>? _selectedFontSize;
/// The current font size, null to use the default one
@Deprecated('No longer used')
MapEntry<String, String>? get selectedFontSize => _selectedFontSize;
@Deprecated('No longer used')
void selectFontSize(MapEntry<String, String>? newFontSize) {
_selectedFontSize = newFontSize;
}
/// For the [QuillToolbarToggleStyleButton]
@Deprecated('No longer used')
final Map<Attribute, bool?> _selectedStyles = {};
/// For the [QuillToolbarToggleStyleButton]
@Deprecated('No longer used')
Map<Attribute, bool?> 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] /// Tells whether to keep or reset the [toggledStyle]
/// when user adds a new line. /// when user adds a new line.
final bool keepStyleOnNewLine; final bool keepStyleOnNewLine;

@ -147,12 +147,6 @@ class QuillToolbarFontFamilyButtonState
options.onSelected?.call(newValue); options.onSelected?.call(newValue);
} }
}); });
if (fontFamily.value == 'Clear') {
controller.selectFontFamily(null);
return;
}
controller.selectFontFamily(fontFamily);
}, },
child: Text( child: Text(
fontFamily.key.toString(), fontFamily.key.toString(),

@ -136,12 +136,6 @@ class QuillToolbarFontSizeButtonState extends QuillToolbarBaseValueButtonState<
options.onSelected?.call(newValue); options.onSelected?.call(newValue);
} }
}); });
if (fontSize.value == '0') {
controller.selectFontSize(null);
return;
}
controller.selectFontSize(fontSize);
}, },
child: Text( child: Text(
fontSize.key.toString(), fontSize.key.toString(),

@ -21,7 +21,9 @@ typedef ToggleStyleButtonBuilder = Widget Function(
QuillIconTheme? iconTheme, QuillIconTheme? iconTheme,
]); ]);
class QuillToolbarToggleStyleButton extends QuillToolbarBaseValueButton<QuillToolbarToggleStyleButtonOptions, QuillToolbarToggleStyleButtonExtraOptions> { class QuillToolbarToggleStyleButton extends QuillToolbarBaseValueButton<
QuillToolbarToggleStyleButtonOptions,
QuillToolbarToggleStyleButtonExtraOptions> {
const QuillToolbarToggleStyleButton({ const QuillToolbarToggleStyleButton({
required super.controller, required super.controller,
required this.attribute, required this.attribute,
@ -32,11 +34,16 @@ class QuillToolbarToggleStyleButton extends QuillToolbarBaseValueButton<QuillToo
final Attribute attribute; final Attribute attribute;
@override @override
QuillToolbarToggleStyleButtonState createState() => QuillToolbarToggleStyleButtonState(); QuillToolbarToggleStyleButtonState createState() =>
QuillToolbarToggleStyleButtonState();
} }
class QuillToolbarToggleStyleButtonState class QuillToolbarToggleStyleButtonState
extends QuillToolbarBaseValueButtonState<QuillToolbarToggleStyleButton, QuillToolbarToggleStyleButtonOptions, QuillToolbarToggleStyleButtonExtraOptions, bool> { extends QuillToolbarBaseValueButtonState<
QuillToolbarToggleStyleButton,
QuillToolbarToggleStyleButtonOptions,
QuillToolbarToggleStyleButtonExtraOptions,
bool> {
Style get _selectionStyle => controller.getSelectionStyle(); Style get _selectionStyle => controller.getSelectionStyle();
@override @override
@ -77,7 +84,10 @@ class QuillToolbarToggleStyleButtonState
'left' => (context.loc.alignLeft, Icons.format_align_left), 'left' => (context.loc.alignLeft, Icons.format_align_left),
'right' => (context.loc.alignRight, Icons.format_align_right), 'right' => (context.loc.alignRight, Icons.format_align_right),
'center' => (context.loc.alignCenter, Icons.format_align_center), '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), Object() => throw ArgumentError(widget.attribute.value),
null => (context.loc.alignCenter, Icons.format_align_center), null => (context.loc.alignCenter, Icons.format_align_center),
}; };
@ -93,7 +103,9 @@ class QuillToolbarToggleStyleButtonState
String get defaultTooltip => _defaultTooltipAndIconData.$1; String get defaultTooltip => _defaultTooltipAndIconData.$1;
IconData get iconData { IconData get iconData {
return options.iconData ?? context.quillToolbarBaseButtonOptions?.iconData ?? _defaultTooltipAndIconData.$2; return options.iconData ??
context.quillToolbarBaseButtonOptions?.iconData ??
_defaultTooltipAndIconData.$2;
} }
void _onPressed() { void _onPressed() {
@ -103,7 +115,8 @@ class QuillToolbarToggleStyleButtonState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final childBuilder = options.childBuilder ?? context.quillToolbarBaseButtonOptions?.childBuilder; final childBuilder = options.childBuilder ??
context.quillToolbarBaseButtonOptions?.childBuilder;
if (childBuilder != null) { if (childBuilder != null) {
return childBuilder( return childBuilder(
options, options,
@ -133,7 +146,9 @@ class QuillToolbarToggleStyleButtonState
} }
bool _getIsToggled(Map<String, Attribute> attrs) { bool _getIsToggled(Map<String, Attribute> 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]; final attribute = attrs[widget.attribute.key];
if (attribute == null) { if (attribute == null) {
return false; return false;
@ -147,9 +162,10 @@ class QuillToolbarToggleStyleButtonState
controller controller
..skipRequestKeyboard = !widget.attribute.isInline ..skipRequestKeyboard = !widget.attribute.isInline
..formatSelection( ..formatSelection(
currentValue ? Attribute.clone(widget.attribute, null) : widget.attribute, currentValue
) ? Attribute.clone(widget.attribute, null)
..selectStyle(widget.attribute, currentValue); : widget.attribute,
);
} }
} }

Loading…
Cancel
Save