Update toolbar.dart

pull/794/head
mark8044 3 years ago committed by GitHub
parent 0f5e869e35
commit 61691637a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      lib/src/widgets/toolbar.dart

@ -110,8 +110,8 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
WebImagePickImpl? webImagePickImpl, WebImagePickImpl? webImagePickImpl,
WebVideoPickImpl? webVideoPickImpl, WebVideoPickImpl? webVideoPickImpl,
///List of font sizes in [int] ///Map of font sizes in [int]
List? fontSizeValues, Map<String, int>? fontSizeValues,
int? initialFontSizeValue, int? initialFontSizeValue,
///The theme to use for the icons in the toolbar, uses type [QuillIconTheme] ///The theme to use for the icons in the toolbar, uses type [QuillIconTheme]
@ -152,7 +152,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
//default font size values //default font size values
final fontSizes = final fontSizes =
fontSizeValues ?? [10, 12, 14, 16, 18, 20, 24, 28, 32, 48]; fontSizeValues ?? {'10':10, '12':12, '14':14, '16':16, '18':18, '20':20, '24':24, '28':28, '32':32, '48':48};
return QuillToolbar( return QuillToolbar(
key: key, key: key,
@ -183,10 +183,10 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
iconTheme: iconTheme, iconTheme: iconTheme,
height: (toolbarIconSize * 2)-(toolbarIconSize / 3), height: (toolbarIconSize * 2)-(toolbarIconSize / 3),
items: [ items: [
for (var fontSize in fontSizes) for(MapEntry<String, int> fontSize in fontSizes.entries)
PopupMenuItem<int>( PopupMenuItem<int>(
value: fontSize, value: fontSize.value,
child: Text(fontSize.toString()), child: Text(fontSize.key.toString()),
), ),
], ],
onSelected: (newSize) { onSelected: (newSize) {
@ -195,7 +195,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
.formatSelection(Attribute.fromKeyValue('size', newSize)); .formatSelection(Attribute.fromKeyValue('size', newSize));
} }
}, },
initialValue: fontSizes[initialFontSizeValue ?? 0], initialValue: fontSizes.values.toList()[initialFontSizeValue ?? 0]
), ),
if (showBoldButton) if (showBoldButton)
ToggleStyleButton( ToggleStyleButton(

Loading…
Cancel
Save