diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d80f938..6c7b543a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## 9.2.1 +* Fix [bug](https://github.com/singerdmx/flutter-quill/issues/1119#issuecomment-1872605246) with font size button + ## 9.2.0 * Require minimum version `6.0.0` of `flutter_keyboard_visibility` to fix some build issues with Android Gradle Plugin 8.2.0 * Add on image clicked in `flutter_quill_extensions` callback diff --git a/example/lib/screens/quill/my_quill_toolbar.dart b/example/lib/screens/quill/my_quill_toolbar.dart index ddf3e171..dde676d2 100644 --- a/example/lib/screens/quill/my_quill_toolbar.dart +++ b/example/lib/screens/quill/my_quill_toolbar.dart @@ -209,6 +209,19 @@ class MyQuillToolbar extends StatelessWidget { 'Formal': GoogleFonts.petitFormalScript().fontFamily!, 'Roboto': GoogleFonts.roboto().fontFamily! }, + fontSizesValues: const { + '14': '14.0', + '16': '16.0', + '18': '18.0', + '20': '20.0', + '22': '22.0', + '24': '24.0', + '26': '26.0', + '28': '28.0', + '30': '30.0', + '35': '35.0', + '40': '40.0' + }, buttonOptions: QuillSimpleToolbarButtonOptions( base: QuillToolbarBaseButtonOptions( afterButtonPressed: focusNode.requestFocus, diff --git a/lib/src/widgets/quill/quill_controller.dart b/lib/src/widgets/quill/quill_controller.dart index b2e076fa..7ea7b9fc 100644 --- a/lib/src/widgets/quill/quill_controller.dart +++ b/lib/src/widgets/quill/quill_controller.dart @@ -81,12 +81,12 @@ class QuillController extends ChangeNotifier { } /// The current font size, null to use the default one - String? _selectedFontSize; + MapEntry? _selectedFontSize; /// The current font size, null to use the default one - String? get selectedFontSize => _selectedFontSize; + MapEntry? get selectedFontSize => _selectedFontSize; - void selectFontSize(String? newFontSize) { + void selectFontSize(MapEntry? newFontSize) { _selectedFontSize = newFontSize; } diff --git a/lib/src/widgets/toolbar/buttons/font_size_button.dart b/lib/src/widgets/toolbar/buttons/font_size_button.dart index 2ed3cb12..1323c1d2 100644 --- a/lib/src/widgets/toolbar/buttons/font_size_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_size_button.dart @@ -181,7 +181,7 @@ class QuillToolbarFontSizeButtonState controller.selectFontSize(null); return; } - controller.selectFontSize(fontSize.value); + controller.selectFontSize(fontSize); }, child: Text( fontSize.key.toString(), @@ -231,7 +231,7 @@ class QuillToolbarFontSizeButtonState enabled: hasFinalWidth, wrapper: (child) => Expanded(child: child), child: Text( - getLabel(widget.controller.selectedFontSize) ?? + getLabel(widget.controller.selectedFontSize?.key) ?? getLabel(_currentValue) ?? '', overflow: options.labelOverflow,