From 4cce50a6f917710f296d4a777113ce5ea0bee331 Mon Sep 17 00:00:00 2001 From: Cheryl Date: Sun, 14 Nov 2021 22:05:24 -0800 Subject: [PATCH] Make toolbar optional params not nullable --- lib/src/widgets/toolbar.dart | 42 +++++++++++++++--------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/lib/src/widgets/toolbar.dart b/lib/src/widgets/toolbar.dart index 2e5899d6..de38da0b 100644 --- a/lib/src/widgets/toolbar.dart +++ b/lib/src/widgets/toolbar.dart @@ -49,8 +49,6 @@ typedef WebVideoPickImpl = Future Function( typedef MediaPickSettingSelector = Future Function( BuildContext context); -enum ToolbarAlignment { start, center, end } - // The default size of the icon of a button. const double kDefaultIconSize = 18; @@ -60,12 +58,12 @@ const double kIconButtonFactor = 1.77; class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { const QuillToolbar({ required this.children, - this.toolBarHeight = 36, - this.toolBarSectionSpacing, - this.toolBarIconAlignment, + this.toolbarHeight = 36, + this.toolbarIconAlignment = WrapAlignment.center, + this.toolbarSectionSpacing = 4, + this.multiRowsDisplay = true, this.color, this.filePickImpl, - this.multiRowsDisplay, this.locale, Key? key, }) : super(key: key); @@ -73,8 +71,8 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { factory QuillToolbar.basic({ required QuillController controller, double toolbarIconSize = kDefaultIconSize, - double toolBarSectionSpacing = 4, - ToolbarAlignment toolBarIconAlignment = ToolbarAlignment.center, + double toolbarSectionSpacing = 4, + WrapAlignment toolbarIconAlignment = WrapAlignment.center, bool showBoldButton = true, bool showItalicButton = true, bool showSmallButton = false, @@ -152,9 +150,9 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { return QuillToolbar( key: key, - toolBarHeight: toolbarIconSize * 2, - toolBarSectionSpacing: toolBarSectionSpacing, - toolBarIconAlignment: toolBarIconAlignment, + toolbarHeight: toolbarIconSize * 2, + toolbarSectionSpacing: toolbarSectionSpacing, + toolbarIconAlignment: toolbarIconAlignment, multiRowsDisplay: multiRowsDisplay, locale: locale, children: [ @@ -416,10 +414,10 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { } final List children; - final double toolBarHeight; - final double? toolBarSectionSpacing; - final ToolbarAlignment? toolBarIconAlignment; - final bool? multiRowsDisplay; + final double toolbarHeight; + final double toolbarSectionSpacing; + final WrapAlignment toolbarIconAlignment; + final bool multiRowsDisplay; /// The color of the toolbar. /// @@ -438,23 +436,17 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { final Locale? locale; @override - Size get preferredSize => Size.fromHeight(toolBarHeight); + Size get preferredSize => Size.fromHeight(toolbarHeight); @override Widget build(BuildContext context) { return I18n( initialLocale: locale, - child: multiRowsDisplay ?? true + child: multiRowsDisplay ? Wrap( - alignment: (toolBarIconAlignment == ToolbarAlignment.start) - ? WrapAlignment.start - : (toolBarIconAlignment == ToolbarAlignment.center) - ? WrapAlignment.center - : (toolBarIconAlignment == ToolbarAlignment.end) - ? WrapAlignment.end - : WrapAlignment.center, + alignment: toolbarIconAlignment, runSpacing: 4, - spacing: toolBarSectionSpacing ?? 4, + spacing: toolbarSectionSpacing, children: children, ) : Container(