diff --git a/lib/src/models/config/toolbar/buttons/dropdown_header_style.dart b/lib/src/models/config/toolbar/buttons/dropdown_header_style.dart index 0d81df20..5936c4f8 100644 --- a/lib/src/models/config/toolbar/buttons/dropdown_header_style.dart +++ b/lib/src/models/config/toolbar/buttons/dropdown_header_style.dart @@ -42,6 +42,7 @@ class QuillToolbarSelectHeaderStyleDropdownButtonOptions this.itemHeight, this.itemPadding, this.defaultItemColor, + this.renderItemTextStyle = false, }); final double? iconSize; @@ -59,6 +60,7 @@ class QuillToolbarSelectHeaderStyleDropdownButtonOptions final double? itemHeight; final EdgeInsets? itemPadding; final Color? defaultItemColor; + final bool renderItemTextStyle; QuillToolbarSelectHeaderStyleDropdownButtonOptions copyWith({ Color? fillColor, @@ -79,12 +81,12 @@ class QuillToolbarSelectHeaderStyleDropdownButtonOptions Color? defaultItemColor, double? iconSize, double? iconButtonFactor, - // Add properties to override inherited properties QuillController? controller, IconData? iconData, VoidCallback? afterButtonPressed, String? tooltip, QuillIconTheme? iconTheme, + bool? renderItemTextStyle, }) { return QuillToolbarSelectHeaderStyleDropdownButtonOptions( attributes: attributes ?? this.attributes, @@ -107,6 +109,7 @@ class QuillToolbarSelectHeaderStyleDropdownButtonOptions fillColor: fillColor ?? this.fillColor, hoverElevation: hoverElevation ?? this.hoverElevation, highlightElevation: highlightElevation ?? this.highlightElevation, + renderItemTextStyle: renderItemTextStyle ?? this.renderItemTextStyle, ); } } diff --git a/lib/src/widgets/toolbar/buttons/dropdown_header_style.dart b/lib/src/widgets/toolbar/buttons/dropdown_header_style.dart index 0ad1b784..25cac749 100644 --- a/lib/src/widgets/toolbar/buttons/dropdown_header_style.dart +++ b/lib/src/widgets/toolbar/buttons/dropdown_header_style.dart @@ -37,6 +37,8 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState Attribute.h6: context.loc.heading6, }; + late final Map _headerTextStyles; + QuillToolbarSelectHeaderStyleDropdownButtonOptions get options { return widget.options; } @@ -102,6 +104,15 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState super.initState(); controller.addListener(_didChangeEditingValue); _selectedAttribute = _getHeaderValue(); + final defaultStyles = QuillStyles.getStyles(context, false); + _headerTextStyles = { + Attribute.h1: defaultStyles!.h1!.style, + Attribute.h2: defaultStyles.h2!.style, + Attribute.h3: defaultStyles.h3!.style, + Attribute.h4: defaultStyles.h4!.style, + Attribute.h5: defaultStyles.h5!.style, + Attribute.h6: defaultStyles.h6!.style, + }; } @override @@ -232,7 +243,12 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState child: Text( header.value, style: TextStyle( - color: header.key == Attribute.header + fontSize: options.renderItemTextStyle + ? _headerTextStyles[header.key]?.fontSize ?? + DefaultTextStyle.of(context).style.fontSize ?? + 14 + : null, + color: header.key == _selectedAttribute ? options.defaultItemColor : null, ),