Fix bug with font size button

pull/1659/head
Ellet 1 year ago
parent 98cf568df8
commit 0f6f8be0f5
  1. 3
      CHANGELOG.md
  2. 13
      example/lib/screens/quill/my_quill_toolbar.dart
  3. 6
      lib/src/widgets/quill/quill_controller.dart
  4. 4
      lib/src/widgets/toolbar/buttons/font_size_button.dart

@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file. 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 ## 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 * 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 * Add on image clicked in `flutter_quill_extensions` callback

@ -209,6 +209,19 @@ class MyQuillToolbar extends StatelessWidget {
'Formal': GoogleFonts.petitFormalScript().fontFamily!, 'Formal': GoogleFonts.petitFormalScript().fontFamily!,
'Roboto': GoogleFonts.roboto().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( buttonOptions: QuillSimpleToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions( base: QuillToolbarBaseButtonOptions(
afterButtonPressed: focusNode.requestFocus, afterButtonPressed: focusNode.requestFocus,

@ -81,12 +81,12 @@ class QuillController extends ChangeNotifier {
} }
/// The current font size, null to use the default one /// The current font size, null to use the default one
String? _selectedFontSize; MapEntry<String, String>? _selectedFontSize;
/// The current font size, null to use the default one /// The current font size, null to use the default one
String? get selectedFontSize => _selectedFontSize; MapEntry<String, String>? get selectedFontSize => _selectedFontSize;
void selectFontSize(String? newFontSize) { void selectFontSize(MapEntry<String, String>? newFontSize) {
_selectedFontSize = newFontSize; _selectedFontSize = newFontSize;
} }

@ -181,7 +181,7 @@ class QuillToolbarFontSizeButtonState
controller.selectFontSize(null); controller.selectFontSize(null);
return; return;
} }
controller.selectFontSize(fontSize.value); controller.selectFontSize(fontSize);
}, },
child: Text( child: Text(
fontSize.key.toString(), fontSize.key.toString(),
@ -231,7 +231,7 @@ class QuillToolbarFontSizeButtonState
enabled: hasFinalWidth, enabled: hasFinalWidth,
wrapper: (child) => Expanded(child: child), wrapper: (child) => Expanded(child: child),
child: Text( child: Text(
getLabel(widget.controller.selectedFontSize) ?? getLabel(widget.controller.selectedFontSize?.key) ??
getLabel(_currentValue) ?? getLabel(_currentValue) ??
'', '',
overflow: options.labelOverflow, overflow: options.labelOverflow,

Loading…
Cancel
Save