Make `options` optional

pull/1621/head
Aleksei 1 year ago
parent fdb001b2a7
commit afcd30d12b
  1. 50
      lib/src/widgets/toolbar/buttons/alignment/select_alignment_button_original.dart
  2. 2
      lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart

@ -13,11 +13,11 @@ import '../../../quill/quill_controller.dart';
class QuillToolbarSelectAlignmentButton extends StatefulWidget { class QuillToolbarSelectAlignmentButton extends StatefulWidget {
const QuillToolbarSelectAlignmentButton({ const QuillToolbarSelectAlignmentButton({
required this.controller, required this.controller,
required this.options, this.options = const QuillToolbarSelectAlignmentButtonOptions(),
this.showLeftAlignment, this.showLeftAlignment = true,
this.showCenterAlignment, this.showCenterAlignment = true,
this.showRightAlignment, this.showRightAlignment = true,
this.showJustifyAlignment, this.showJustifyAlignment = true,
this.padding, this.padding,
super.key, super.key,
}); });
@ -25,10 +25,10 @@ class QuillToolbarSelectAlignmentButton extends StatefulWidget {
final QuillController controller; final QuillController controller;
final QuillToolbarSelectAlignmentButtonOptions options; final QuillToolbarSelectAlignmentButtonOptions options;
final bool? showLeftAlignment; final bool showLeftAlignment;
final bool? showCenterAlignment; final bool showCenterAlignment;
final bool? showRightAlignment; final bool showRightAlignment;
final bool? showJustifyAlignment; final bool showJustifyAlignment;
final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? padding;
@override @override
@ -156,27 +156,27 @@ class QuillToolbarSelectAlignmentButtonState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final valueToText = <Attribute, String>{ final valueToText = <Attribute, String>{
if (widget.showLeftAlignment!) if (widget.showLeftAlignment)
Attribute.leftAlignment: Attribute.leftAlignment.value!, Attribute.leftAlignment: Attribute.leftAlignment.value!,
if (widget.showCenterAlignment!) if (widget.showCenterAlignment)
Attribute.centerAlignment: Attribute.centerAlignment.value!, Attribute.centerAlignment: Attribute.centerAlignment.value!,
if (widget.showRightAlignment!) if (widget.showRightAlignment)
Attribute.rightAlignment: Attribute.rightAlignment.value!, Attribute.rightAlignment: Attribute.rightAlignment.value!,
if (widget.showJustifyAlignment!) if (widget.showJustifyAlignment)
Attribute.justifyAlignment: Attribute.justifyAlignment.value!, Attribute.justifyAlignment: Attribute.justifyAlignment.value!,
}; };
final valueAttribute = <Attribute>[ final valueAttribute = <Attribute>[
if (widget.showLeftAlignment!) Attribute.leftAlignment, if (widget.showLeftAlignment) Attribute.leftAlignment,
if (widget.showCenterAlignment!) Attribute.centerAlignment, if (widget.showCenterAlignment) Attribute.centerAlignment,
if (widget.showRightAlignment!) Attribute.rightAlignment, if (widget.showRightAlignment) Attribute.rightAlignment,
if (widget.showJustifyAlignment!) Attribute.justifyAlignment if (widget.showJustifyAlignment) Attribute.justifyAlignment
]; ];
final valueString = <String>[ final valueString = <String>[
if (widget.showLeftAlignment!) Attribute.leftAlignment.value!, if (widget.showLeftAlignment) Attribute.leftAlignment.value!,
if (widget.showCenterAlignment!) Attribute.centerAlignment.value!, if (widget.showCenterAlignment) Attribute.centerAlignment.value!,
if (widget.showRightAlignment!) Attribute.rightAlignment.value!, if (widget.showRightAlignment) Attribute.rightAlignment.value!,
if (widget.showJustifyAlignment!) Attribute.justifyAlignment.value!, if (widget.showJustifyAlignment) Attribute.justifyAlignment.value!,
]; ];
// final _valueToButtons = <Attribute, ToolbarButtons>{ // final _valueToButtons = <Attribute, ToolbarButtons>{
// if (widget.showLeftAlignment!) // if (widget.showLeftAlignment!)
@ -189,10 +189,10 @@ class QuillToolbarSelectAlignmentButtonState
// Attribute.justifyAlignment: ToolbarButtons.justifyAlignment, // Attribute.justifyAlignment: ToolbarButtons.justifyAlignment,
// }; // };
final buttonCount = ((widget.showLeftAlignment!) ? 1 : 0) + final buttonCount = ((widget.showLeftAlignment) ? 1 : 0) +
((widget.showCenterAlignment!) ? 1 : 0) + ((widget.showCenterAlignment) ? 1 : 0) +
((widget.showRightAlignment!) ? 1 : 0) + ((widget.showRightAlignment) ? 1 : 0) +
((widget.showJustifyAlignment!) ? 1 : 0); ((widget.showJustifyAlignment) ? 1 : 0);
final childBuilder = final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder; options.childBuilder ?? baseButtonExtraOptions.childBuilder;

@ -14,7 +14,7 @@ import '../../../quill/quill_controller.dart';
class QuillToolbarSelectHeaderStyleDropdownButton extends StatefulWidget { class QuillToolbarSelectHeaderStyleDropdownButton extends StatefulWidget {
const QuillToolbarSelectHeaderStyleDropdownButton({ const QuillToolbarSelectHeaderStyleDropdownButton({
required this.controller, required this.controller,
required this.options, this.options = const QuillToolbarSelectHeaderStyleDropdownButtonOptions(),
super.key, super.key,
}); });

Loading…
Cancel
Save