Remove require toolbar options (#1626)

* Revert "Fix build error"

This reverts commit 90738e1ece.

* Revert "Prepare to release 9.1.0"

This reverts commit c3d57b87ec.

* Revert "Revert from material 3 to material 2"

This reverts commit 07b8f40491.

* Revert "Restore old feel and look (#1621)"

This reverts commit e820c5b29d.

* Allow to use most of the buttons without internal provider

---------

Co-authored-by: Ellet <ellet@freshplatform.net>
pull/1631/head
Ellet Hnewa 1 year ago committed by GitHub
parent 05a8d9b4f3
commit 55db4a721f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 22
      flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart
  3. 22
      flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart
  4. 26
      flutter_quill_extensions/lib/embeds/others/camera_button/camera_button.dart
  5. 22
      flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart
  6. 9
      lib/src/extensions/quill_configurations_ext.dart
  7. 22
      lib/src/widgets/toolbar/buttons/clear_format_button.dart
  8. 22
      lib/src/widgets/toolbar/buttons/color/color_button.dart
  9. 20
      lib/src/widgets/toolbar/buttons/custom_button_button.dart
  10. 18
      lib/src/widgets/toolbar/buttons/font_family_button.dart
  11. 15
      lib/src/widgets/toolbar/buttons/font_size_button.dart
  12. 20
      lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_buttons.dart
  13. 11
      lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart
  14. 21
      lib/src/widgets/toolbar/buttons/history_button.dart
  15. 24
      lib/src/widgets/toolbar/buttons/indent_button.dart
  16. 22
      lib/src/widgets/toolbar/buttons/link_style2_button.dart
  17. 22
      lib/src/widgets/toolbar/buttons/link_style_button.dart
  18. 22
      lib/src/widgets/toolbar/buttons/search/search_button.dart
  19. 26
      lib/src/widgets/toolbar/buttons/toggle_check_list_button.dart
  20. 4
      lib/src/widgets/toolbar/buttons/toggle_style_button.dart
  21. 2
      lib/src/widgets/toolbar/simple_toolbar.dart

@ -2,10 +2,12 @@
All notable changes to this project will be documented in this file.
## 9.0.5
* You can now use most of the buttons without internal provider
## 9.0.4
* Feature: [#1611](https://github.com/singerdmx/flutter-quill/issues/1611)
* Export missing widgets
* Revert changes of (revert material 3 to 2)
## 9.0.3
* Flutter Quill Extensions:

@ -14,40 +14,40 @@ class QuillToolbarFormulaButton extends StatelessWidget {
final QuillToolbarFormulaButtonOptions options;
double _iconSize(BuildContext context) {
final baseFontSize = baseButtonExtraOptions(context).globalIconSize;
final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double _iconButtonFactor(BuildContext context) {
final baseIconFactor =
baseButtonExtraOptions(context).globalIconButtonFactor;
baseButtonExtraOptions(context)?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? _afterButtonPressed(BuildContext context) {
return options.afterButtonPressed ??
baseButtonExtraOptions(context).afterButtonPressed;
baseButtonExtraOptions(context)?.afterButtonPressed;
}
QuillIconTheme? _iconTheme(BuildContext context) {
return options.iconTheme ?? baseButtonExtraOptions(context).iconTheme;
return options.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme;
}
QuillToolbarBaseButtonOptions baseButtonExtraOptions(BuildContext context) {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) {
return context.quillToolbarBaseButtonOptions;
}
IconData _iconData(BuildContext context) {
return options.iconData ??
baseButtonExtraOptions(context).iconData ??
baseButtonExtraOptions(context)?.iconData ??
Icons.functions;
}
String _tooltip(BuildContext context) {
return options.tooltip ??
baseButtonExtraOptions(context).tooltip ??
baseButtonExtraOptions(context)?.tooltip ??
'Insert formula';
// ('Insert formula'.i18n);
}
@ -68,7 +68,7 @@ class QuillToolbarFormulaButton extends StatelessWidget {
final iconButtonFactor = _iconButtonFactor(context);
final iconData = _iconData(context);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context).childBuilder;
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;

@ -23,40 +23,40 @@ class QuillToolbarImageButton extends StatelessWidget {
final QuillToolbarImageButtonOptions options;
double _iconSize(BuildContext context) {
final baseFontSize = baseButtonExtraOptions(context).globalIconSize;
final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double _iconButtonFactor(BuildContext context) {
final baseIconFactor =
baseButtonExtraOptions(context).globalIconButtonFactor;
baseButtonExtraOptions(context)?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? _afterButtonPressed(BuildContext context) {
return options.afterButtonPressed ??
baseButtonExtraOptions(context).afterButtonPressed;
baseButtonExtraOptions(context)?.afterButtonPressed;
}
QuillIconTheme? _iconTheme(BuildContext context) {
return options.iconTheme ?? baseButtonExtraOptions(context).iconTheme;
return options.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme;
}
QuillToolbarBaseButtonOptions baseButtonExtraOptions(BuildContext context) {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) {
return context.quillToolbarBaseButtonOptions;
}
IconData _iconData(BuildContext context) {
return options.iconData ??
baseButtonExtraOptions(context).iconData ??
baseButtonExtraOptions(context)?.iconData ??
Icons.image;
}
String _tooltip(BuildContext context) {
return options.tooltip ??
baseButtonExtraOptions(context).tooltip ??
baseButtonExtraOptions(context)?.tooltip ??
context.loc.insertImage;
}
@ -72,7 +72,7 @@ class QuillToolbarImageButton extends StatelessWidget {
final iconButtonFactor = _iconButtonFactor(context);
final iconData = _iconData(context);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context).childBuilder;
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
if (childBuilder != null) {
return childBuilder(

@ -5,7 +5,9 @@ import 'package:flutter_quill/flutter_quill.dart'
QuillIconTheme,
QuillSimpleToolbarExt,
QuillToolbarBaseButtonOptions,
QuillToolbarIconButton;
QuillToolbarIconButton,
kDefaultIconSize,
kIconButtonFactor;
import 'package:flutter_quill/translations.dart';
import '../../../models/config/shared_configurations.dart';
@ -25,40 +27,40 @@ class QuillToolbarCameraButton extends StatelessWidget {
final QuillToolbarCameraButtonOptions options;
double _iconSize(BuildContext context) {
final baseFontSize = baseButtonExtraOptions(context).globalIconSize;
final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double _iconButtonFactor(BuildContext context) {
final baseIconFactor =
baseButtonExtraOptions(context).globalIconButtonFactor;
baseButtonExtraOptions(context)?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? _afterButtonPressed(BuildContext context) {
return options.afterButtonPressed ??
baseButtonExtraOptions(context).afterButtonPressed;
baseButtonExtraOptions(context)?.afterButtonPressed;
}
QuillIconTheme? _iconTheme(BuildContext context) {
return options.iconTheme ?? baseButtonExtraOptions(context).iconTheme;
return options.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme;
}
QuillToolbarBaseButtonOptions baseButtonExtraOptions(BuildContext context) {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) {
return context.quillToolbarBaseButtonOptions;
}
IconData _iconData(BuildContext context) {
return options.iconData ??
baseButtonExtraOptions(context).iconData ??
baseButtonExtraOptions(context)?.iconData ??
Icons.photo_camera;
}
String _tooltip(BuildContext context) {
return options.tooltip ??
baseButtonExtraOptions(context).tooltip ??
baseButtonExtraOptions(context)?.tooltip ??
context.loc.camera;
}
@ -79,7 +81,7 @@ class QuillToolbarCameraButton extends StatelessWidget {
final iconButtonFactor = _iconButtonFactor(context);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context).childBuilder;
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
if (childBuilder != null) {
childBuilder(

@ -23,40 +23,40 @@ class QuillToolbarVideoButton extends StatelessWidget {
final QuillToolbarVideoButtonOptions options;
double _iconSize(BuildContext context) {
final baseFontSize = baseButtonExtraOptions(context).globalIconSize;
final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double _iconButtonFactor(BuildContext context) {
final baseIconFactor =
baseButtonExtraOptions(context).globalIconButtonFactor;
baseButtonExtraOptions(context)?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? _afterButtonPressed(BuildContext context) {
return options.afterButtonPressed ??
baseButtonExtraOptions(context).afterButtonPressed;
baseButtonExtraOptions(context)?.afterButtonPressed;
}
QuillIconTheme? _iconTheme(BuildContext context) {
return options.iconTheme ?? baseButtonExtraOptions(context).iconTheme;
return options.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme;
}
QuillToolbarBaseButtonOptions baseButtonExtraOptions(BuildContext context) {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) {
return context.quillToolbarBaseButtonOptions;
}
IconData _iconData(BuildContext context) {
return options.iconData ??
baseButtonExtraOptions(context).iconData ??
baseButtonExtraOptions(context)?.iconData ??
Icons.movie_creation;
}
String _tooltip(BuildContext context) {
return options.tooltip ??
baseButtonExtraOptions(context).tooltip ??
baseButtonExtraOptions(context)?.tooltip ??
'Insert video';
// ('Insert video'.i18n);
}
@ -77,7 +77,7 @@ class QuillToolbarVideoButton extends StatelessWidget {
final iconButtonFactor = _iconButtonFactor(context);
final iconData = _iconData(context);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context).childBuilder;
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
final iconFillColor = iconTheme?.iconUnselectedFillColor ??

@ -69,15 +69,6 @@ extension QuillSimpleToolbarExt on BuildContext {
QuillToolbarBaseButtonOptions? get quillToolbarBaseButtonOptions {
return quillSimpleToolbarConfigurations?.buttonOptions.base;
}
/// return [QuillToolbarBaseButtonOptions] as not null.
QuillToolbarBaseButtonOptions get requireQuillToolbarBaseButtonOptions {
return quillSimpleToolbarConfigurations?.buttonOptions.base ??
quillToolbarConfigurations?.buttonOptions.base ??
(throw ArgumentError(
"The buttonOptions is required and it's null because the toolbar configurations is.",
));
}
}
extension QuillToolbarExt on BuildContext {

@ -22,40 +22,40 @@ class QuillToolbarClearFormatButton extends StatelessWidget {
}
double _iconSize(BuildContext context) {
final baseFontSize = baseButtonExtraOptions(context).globalIconSize;
final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double _iconButtonFactor(BuildContext context) {
final baseIconFactor =
baseButtonExtraOptions(context).globalIconButtonFactor;
baseButtonExtraOptions(context)?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? _afterButtonPressed(BuildContext context) {
return options.afterButtonPressed ??
baseButtonExtraOptions(context).afterButtonPressed;
baseButtonExtraOptions(context)?.afterButtonPressed;
}
QuillIconTheme? _iconTheme(BuildContext context) {
return options.iconTheme ?? baseButtonExtraOptions(context).iconTheme;
return options.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme;
}
QuillToolbarBaseButtonOptions baseButtonExtraOptions(BuildContext context) {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) {
return context.quillToolbarBaseButtonOptions;
}
IconData _iconData(BuildContext context) {
return options.iconData ??
baseButtonExtraOptions(context).iconData ??
baseButtonExtraOptions(context)?.iconData ??
Icons.format_clear;
}
String _tooltip(BuildContext context) {
return options.tooltip ??
baseButtonExtraOptions(context).tooltip ??
baseButtonExtraOptions(context)?.tooltip ??
(context.loc.clearFormat);
}
@ -80,7 +80,7 @@ class QuillToolbarClearFormatButton extends StatelessWidget {
final iconData = _iconData(context);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context).childBuilder;
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
final afterButtonPressed = _afterButtonPressed(context);
if (childBuilder != null) {

@ -105,39 +105,39 @@ class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
}
double get iconSize {
final baseFontSize = baseButtonExtraOptions.globalIconSize;
final baseFontSize = baseButtonExtraOptions?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double get iconButtonFactor {
final baseIconFactor = baseButtonExtraOptions.globalIconButtonFactor;
final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? get afterButtonPressed {
return options.afterButtonPressed ??
baseButtonExtraOptions.afterButtonPressed;
baseButtonExtraOptions?.afterButtonPressed;
}
QuillIconTheme? get iconTheme {
return options.iconTheme ?? baseButtonExtraOptions.iconTheme;
return options.iconTheme ?? baseButtonExtraOptions?.iconTheme;
}
QuillToolbarBaseButtonOptions get baseButtonExtraOptions {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? get baseButtonExtraOptions {
return context.quillToolbarBaseButtonOptions;
}
IconData get iconData {
return options.iconData ??
baseButtonExtraOptions.iconData ??
baseButtonExtraOptions?.iconData ??
(widget.isBackground ? Icons.format_color_fill : Icons.color_lens);
}
String get tooltip {
return options.tooltip ??
baseButtonExtraOptions.tooltip ??
baseButtonExtraOptions?.tooltip ??
(widget.isBackground
? context.loc.backgroundColor
: context.loc.fontColor);
@ -164,7 +164,7 @@ class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
: (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder;
options.childBuilder ?? baseButtonExtraOptions?.childBuilder;
if (childBuilder != null) {
// if the caller using Cupertino app he might need to wrap the builder
// with Material() widget

@ -16,33 +16,33 @@ class QuillToolbarCustomButton extends StatelessWidget {
final QuillToolbarCustomButtonOptions options;
double _iconSize(BuildContext context) {
final baseFontSize = baseButtonExtraOptions(context).globalIconSize;
final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double _iconButtonFactor(BuildContext context) {
final baseIconFactor =
baseButtonExtraOptions(context).globalIconButtonFactor;
baseButtonExtraOptions(context)?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? _afterButtonPressed(BuildContext context) {
return options.afterButtonPressed ??
baseButtonExtraOptions(context).afterButtonPressed;
baseButtonExtraOptions(context)?.afterButtonPressed;
}
QuillIconTheme? _iconTheme(BuildContext context) {
return options.iconTheme ?? baseButtonExtraOptions(context).iconTheme;
return options.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme;
}
QuillToolbarBaseButtonOptions baseButtonExtraOptions(BuildContext context) {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) {
return context.quillToolbarBaseButtonOptions;
}
String? _tooltip(BuildContext context) {
return options.tooltip ?? baseButtonExtraOptions(context).tooltip;
return options.tooltip ?? baseButtonExtraOptions(context)?.tooltip;
}
void _onPressed(BuildContext context) {
@ -58,7 +58,7 @@ class QuillToolbarCustomButton extends StatelessWidget {
final iconButtonFactor = _iconButtonFactor(context);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context).childBuilder;
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
final afterButtonPressed = _afterButtonPressed(context);
if (childBuilder != null) {

@ -3,10 +3,10 @@ import 'package:flutter/material.dart';
import '../../../../extensions.dart';
import '../../../extensions/quill_configurations_ext.dart';
import '../../../l10n/extensions/localizations.dart';
import '../../../models/config/toolbar/buttons/font_family_configurations.dart';
import '../../../models/documents/attribute.dart';
import '../../../models/themes/quill_icon_theme.dart';
import '../../quill/quill_controller.dart';
import '../base_toolbar.dart';
class QuillToolbarFontFamilyButton extends StatefulWidget {
QuillToolbarFontFamilyButton({
@ -116,25 +116,24 @@ class QuillToolbarFontFamilyButtonState
}
double get iconSize {
final baseFontSize =
context.requireQuillToolbarBaseButtonOptions.globalIconSize;
final baseFontSize = context.quillToolbarBaseButtonOptions?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
VoidCallback? get afterButtonPressed {
return options.afterButtonPressed ??
context.requireQuillToolbarBaseButtonOptions.afterButtonPressed;
context.quillToolbarBaseButtonOptions?.afterButtonPressed;
}
QuillIconTheme? get iconTheme {
return options.iconTheme ??
context.requireQuillToolbarBaseButtonOptions.iconTheme;
context.quillToolbarBaseButtonOptions?.iconTheme;
}
String get tooltip {
return options.tooltip ??
context.requireQuillToolbarBaseButtonOptions.tooltip ??
context.quillToolbarBaseButtonOptions?.tooltip ??
context.loc.fontFamily;
}
@ -145,10 +144,9 @@ class QuillToolbarFontFamilyButtonState
@override
Widget build(BuildContext context) {
final baseButtonConfigurations =
context.requireQuillToolbarBaseButtonOptions;
final baseButtonConfigurations = context.quillToolbarBaseButtonOptions;
final childBuilder =
options.childBuilder ?? baseButtonConfigurations.childBuilder;
options.childBuilder ?? baseButtonConfigurations?.childBuilder;
if (childBuilder != null) {
return childBuilder(
options.copyWith(

@ -88,24 +88,24 @@ class QuillToolbarFontSizeButtonState
double get iconButtonFactor {
final baseIconFactor =
context.requireQuillToolbarBaseButtonOptions.globalIconButtonFactor;
context.quillToolbarBaseButtonOptions?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? get afterButtonPressed {
return options.afterButtonPressed ??
context.requireQuillToolbarBaseButtonOptions.afterButtonPressed;
context.quillToolbarBaseButtonOptions?.afterButtonPressed;
}
QuillIconTheme? get iconTheme {
return options.iconTheme ??
context.requireQuillToolbarBaseButtonOptions.iconTheme;
context.quillToolbarBaseButtonOptions?.iconTheme;
}
String get tooltip {
return options.tooltip ??
context.requireQuillToolbarBaseButtonOptions.tooltip ??
context.quillToolbarBaseButtonOptions?.tooltip ??
context.loc.fontSize;
}
@ -116,10 +116,9 @@ class QuillToolbarFontSizeButtonState
@override
Widget build(BuildContext context) {
final baseButtonConfigurations =
context.requireQuillToolbarBaseButtonOptions;
final baseButtonConfigurations = context.quillToolbarBaseButtonOptions;
final childBuilder =
options.childBuilder ?? baseButtonConfigurations.childBuilder;
options.childBuilder ?? baseButtonConfigurations?.childBuilder;
if (childBuilder != null) {
return childBuilder(
options.copyWith(

@ -56,33 +56,33 @@ class QuillToolbarSelectHeaderStyleButtonsState
}
double get iconSize {
final baseFontSize = baseButtonExtraOptions.globalIconSize;
final baseFontSize = baseButtonExtraOptions?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double get iconButtonFactor {
final baseIconFactor = baseButtonExtraOptions.globalIconButtonFactor;
final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? get afterButtonPressed {
return options.afterButtonPressed ??
baseButtonExtraOptions.afterButtonPressed;
baseButtonExtraOptions?.afterButtonPressed;
}
QuillIconTheme? get iconTheme {
return options.iconTheme ?? baseButtonExtraOptions.iconTheme;
return options.iconTheme ?? baseButtonExtraOptions?.iconTheme;
}
QuillToolbarBaseButtonOptions get baseButtonExtraOptions {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? get baseButtonExtraOptions {
return context.quillToolbarBaseButtonOptions;
}
String get tooltip {
return options.tooltip ??
baseButtonExtraOptions.tooltip ??
baseButtonExtraOptions?.tooltip ??
context.loc.headerStyle;
}
@ -126,7 +126,7 @@ class QuillToolbarSelectHeaderStyleButtonsState
);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder;
options.childBuilder ?? baseButtonExtraOptions?.childBuilder;
final children = _attrbuites.map((attribute) {
if (childBuilder != null) {

@ -119,13 +119,13 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState
];
}
QuillToolbarBaseButtonOptions get baseButtonExtraOptions {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? get baseButtonExtraOptions {
return context.quillToolbarBaseButtonOptions;
}
VoidCallback? get afterButtonPressed {
return widget.options.afterButtonPressed ??
baseButtonExtraOptions.afterButtonPressed;
baseButtonExtraOptions?.afterButtonPressed;
}
void _onPressed(Attribute<int?> e) {
@ -135,10 +135,9 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState
@override
Widget build(BuildContext context) {
final baseButtonConfigurations =
context.requireQuillToolbarBaseButtonOptions;
final baseButtonConfigurations = context.quillToolbarBaseButtonOptions;
final childBuilder =
widget.options.childBuilder ?? baseButtonConfigurations.childBuilder;
widget.options.childBuilder ?? baseButtonConfigurations?.childBuilder;
if (childBuilder != null) {
return childBuilder(
widget.options.copyWith(

@ -54,24 +54,25 @@ class QuillToolbarHistoryButtonState extends State<QuillToolbarHistoryButton> {
@override
Widget build(BuildContext context) {
final baseButtonConfigurations =
context.requireQuillToolbarBaseButtonOptions;
final baseButtonConfigurations = context.quillToolbarBaseButtonOptions;
final tooltip = options.tooltip ??
baseButtonConfigurations.tooltip ??
baseButtonConfigurations?.tooltip ??
(widget.isUndo ? context.loc.undo : context.loc.redo);
final iconData = options.iconData ??
baseButtonConfigurations.iconData ??
baseButtonConfigurations?.iconData ??
(widget.isUndo ? Icons.undo_outlined : Icons.redo_outlined);
final childBuilder =
options.childBuilder ?? baseButtonConfigurations.childBuilder;
final iconSize =
options.iconSize ?? baseButtonConfigurations.globalIconSize;
options.childBuilder ?? baseButtonConfigurations?.childBuilder;
final iconSize = options.iconSize ??
baseButtonConfigurations?.globalIconSize ??
kDefaultIconSize;
final iconButtonFactor = options.iconButtonFactor ??
baseButtonConfigurations.globalIconButtonFactor;
final iconTheme = options.iconTheme ?? baseButtonConfigurations.iconTheme;
baseButtonConfigurations?.globalIconButtonFactor ??
kIconButtonFactor;
final iconTheme = options.iconTheme ?? baseButtonConfigurations?.iconTheme;
final afterButtonPressed = options.afterButtonPressed ??
baseButtonConfigurations.afterButtonPressed;
baseButtonConfigurations?.afterButtonPressed;
if (childBuilder != null) {
return childBuilder(

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import '../../../extensions/quill_configurations_ext.dart';
import '../../../l10n/extensions/localizations.dart';
import '../../../models/config/toolbar/buttons/indent_configurations.dart';
import '../../../models/config/toolbar/simple_toolbar_configurations.dart';
import '../../../models/themes/quill_icon_theme.dart';
import '../../quill/quill_controller.dart';
import '../base_toolbar.dart'
@ -35,33 +35,33 @@ class QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> {
}
double get iconSize {
final baseFontSize = baseButtonExtraOptions.globalIconSize;
final baseFontSize = baseButtonExtraOptions?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double get iconButtonFactor {
final baseIconFactor = baseButtonExtraOptions.globalIconButtonFactor;
final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? get afterButtonPressed {
return options.afterButtonPressed ??
baseButtonExtraOptions.afterButtonPressed;
baseButtonExtraOptions?.afterButtonPressed;
}
QuillIconTheme? get iconTheme {
return options.iconTheme ?? baseButtonExtraOptions.iconTheme;
return options.iconTheme ?? baseButtonExtraOptions?.iconTheme;
}
QuillToolbarBaseButtonOptions get baseButtonExtraOptions {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? get baseButtonExtraOptions {
return context.quillToolbarBaseButtonOptions;
}
IconData get iconData {
return options.iconData ??
baseButtonExtraOptions.iconData ??
baseButtonExtraOptions?.iconData ??
(widget.isIncrease
? Icons.format_indent_increase
: Icons.format_indent_decrease);
@ -69,7 +69,7 @@ class QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> {
String get tooltip {
return options.tooltip ??
baseButtonExtraOptions.tooltip ??
baseButtonExtraOptions?.tooltip ??
(widget.isIncrease
? context.loc.increaseIndent
: context.loc.decreaseIndent);
@ -82,7 +82,7 @@ class QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> {
@override
Widget build(BuildContext context) {
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder;
options.childBuilder ?? baseButtonExtraOptions?.childBuilder;
if (childBuilder != null) {
return childBuilder(

@ -70,38 +70,38 @@ class _QuillToolbarLinkStyleButton2State
}
double get iconSize {
final baseFontSize = baseButtonExtraOptions.globalIconSize;
final baseFontSize = baseButtonExtraOptions?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double get iconButtonFactor {
final baseIconFactor = baseButtonExtraOptions.globalIconButtonFactor;
final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? get afterButtonPressed {
return options.afterButtonPressed ??
baseButtonExtraOptions.afterButtonPressed;
baseButtonExtraOptions?.afterButtonPressed;
}
QuillIconTheme? get iconTheme {
return options.iconTheme ?? baseButtonExtraOptions.iconTheme;
return options.iconTheme ?? baseButtonExtraOptions?.iconTheme;
}
QuillToolbarBaseButtonOptions get baseButtonExtraOptions {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? get baseButtonExtraOptions {
return context.quillToolbarBaseButtonOptions;
}
String get tooltip {
return options.tooltip ??
baseButtonExtraOptions.tooltip ??
baseButtonExtraOptions?.tooltip ??
context.loc.insertURL;
}
IconData get iconData {
return options.iconData ?? baseButtonExtraOptions.iconData ?? Icons.link;
return options.iconData ?? baseButtonExtraOptions?.iconData ?? Icons.link;
}
Color get dialogBarrierColor {
@ -113,7 +113,7 @@ class _QuillToolbarLinkStyleButton2State
@override
Widget build(BuildContext context) {
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder;
options.childBuilder ?? baseButtonExtraOptions?.childBuilder;
if (childBuilder != null) {
return childBuilder(
QuillToolbarLinkStyleButton2Options(

@ -63,38 +63,38 @@ class QuillToolbarLinkStyleButtonState
}
double get iconSize {
final baseFontSize = baseButtonExtraOptions.globalIconSize;
final baseFontSize = baseButtonExtraOptions?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double get iconButtonFactor {
final baseIconFactor = baseButtonExtraOptions.globalIconButtonFactor;
final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? get afterButtonPressed {
return options.afterButtonPressed ??
baseButtonExtraOptions.afterButtonPressed;
baseButtonExtraOptions?.afterButtonPressed;
}
QuillIconTheme? get iconTheme {
return options.iconTheme ?? baseButtonExtraOptions.iconTheme;
return options.iconTheme ?? baseButtonExtraOptions?.iconTheme;
}
QuillToolbarBaseButtonOptions get baseButtonExtraOptions {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? get baseButtonExtraOptions {
return context.quillToolbarBaseButtonOptions;
}
String get tooltip {
return options.tooltip ??
baseButtonExtraOptions.tooltip ??
baseButtonExtraOptions?.tooltip ??
context.loc.insertURL;
}
IconData get iconData {
return options.iconData ?? baseButtonExtraOptions.iconData ?? Icons.link;
return options.iconData ?? baseButtonExtraOptions?.iconData ?? Icons.link;
}
Color get dialogBarrierColor {
@ -112,7 +112,7 @@ class QuillToolbarLinkStyleButtonState
final isToggled = _getLinkAttributeValue() != null;
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder;
options.childBuilder ?? baseButtonExtraOptions?.childBuilder;
if (childBuilder != null) {
return childBuilder(
QuillToolbarLinkStyleButtonOptions(

@ -23,40 +23,40 @@ class QuillToolbarSearchButton extends StatelessWidget {
}
double _iconSize(BuildContext context) {
final baseFontSize = baseButtonExtraOptions(context).globalIconSize;
final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double _iconButtonFactor(BuildContext context) {
final baseIconFactor =
baseButtonExtraOptions(context).globalIconButtonFactor;
baseButtonExtraOptions(context)?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? _afterButtonPressed(BuildContext context) {
return options.afterButtonPressed ??
baseButtonExtraOptions(context).afterButtonPressed;
baseButtonExtraOptions(context)?.afterButtonPressed;
}
QuillIconTheme? _iconTheme(BuildContext context) {
return options.iconTheme ?? baseButtonExtraOptions(context).iconTheme;
return options.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme;
}
QuillToolbarBaseButtonOptions baseButtonExtraOptions(BuildContext context) {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) {
return context.quillToolbarBaseButtonOptions;
}
IconData _iconData(BuildContext context) {
return options.iconData ??
baseButtonExtraOptions(context).iconData ??
baseButtonExtraOptions(context)?.iconData ??
Icons.search;
}
String _tooltip(BuildContext context) {
return options.tooltip ??
baseButtonExtraOptions(context).tooltip ??
baseButtonExtraOptions(context)?.tooltip ??
(context.loc.search);
}
@ -81,7 +81,7 @@ class QuillToolbarSearchButton extends StatelessWidget {
final afterButtonPressed = _afterButtonPressed(context);
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context).childBuilder;
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
if (childBuilder != null) {
return childBuilder(

@ -2,14 +2,12 @@ import 'package:flutter/material.dart';
import '../../../extensions/quill_configurations_ext.dart';
import '../../../l10n/extensions/localizations.dart';
import '../../../models/config/toolbar/base_button_configurations.dart';
import '../../../models/config/toolbar/buttons/toggle_check_list_configurations.dart';
import '../../../models/documents/attribute.dart';
import '../../../models/documents/style.dart';
import '../../../models/themes/quill_icon_theme.dart';
import '../../../utils/widgets.dart';
import '../../quill/quill_controller.dart';
import 'toggle_style_button.dart';
import '../base_toolbar.dart';
class QuillToolbarToggleCheckListButton extends StatefulWidget {
const QuillToolbarToggleCheckListButton({
@ -88,46 +86,46 @@ class QuillToolbarToggleCheckListButtonState
}
double get iconSize {
final baseFontSize = baseButtonExtraOptions.globalIconSize;
final baseFontSize = baseButtonExtraOptions?.globalIconSize;
final iconSize = options.iconSize;
return iconSize ?? baseFontSize;
return iconSize ?? baseFontSize ?? kDefaultIconSize;
}
double get iconButtonFactor {
final baseIconFactor = baseButtonExtraOptions.globalIconButtonFactor;
final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? get afterButtonPressed {
return options.afterButtonPressed ??
baseButtonExtraOptions.afterButtonPressed;
baseButtonExtraOptions?.afterButtonPressed;
}
QuillIconTheme? get iconTheme {
return options.iconTheme ?? baseButtonExtraOptions.iconTheme;
return options.iconTheme ?? baseButtonExtraOptions?.iconTheme;
}
QuillToolbarBaseButtonOptions get baseButtonExtraOptions {
return context.requireQuillToolbarBaseButtonOptions;
QuillToolbarBaseButtonOptions? get baseButtonExtraOptions {
return context.quillToolbarBaseButtonOptions;
}
IconData get iconData {
return options.iconData ??
baseButtonExtraOptions.iconData ??
baseButtonExtraOptions?.iconData ??
Icons.check_box;
}
String get tooltip {
return options.tooltip ??
baseButtonExtraOptions.tooltip ??
baseButtonExtraOptions?.tooltip ??
context.loc.checkedList;
}
@override
Widget build(BuildContext context) {
final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder;
options.childBuilder ?? baseButtonExtraOptions?.childBuilder;
if (childBuilder != null) {
return childBuilder(
QuillToolbarToggleCheckListButtonOptions(

@ -69,9 +69,9 @@ class QuillToolbarToggleStyleButtonState
double get iconButtonFactor {
final baseIconFactor =
context.requireQuillToolbarBaseButtonOptions.globalIconButtonFactor;
context.quillToolbarBaseButtonOptions?.globalIconButtonFactor;
final iconButtonFactor = options.iconButtonFactor;
return iconButtonFactor ?? baseIconFactor;
return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor;
}
VoidCallback? get afterButtonPressed {

@ -155,7 +155,7 @@ class QuillSimpleToolbar extends StatelessWidget
builder(
globalController,
globalIconSize,
context.requireQuillToolbarBaseButtonOptions.iconTheme,
context.quillToolbarBaseButtonOptions?.iconTheme,
configurations.dialogTheme),
if (configurations.showDividers &&
isButtonGroupShown[0] &&

Loading…
Cancel
Save