Skip to content

Commit 4cce50a

Browse files
Make toolbar optional params not nullable
1 parent 0dedb1c commit 4cce50a

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

lib/src/widgets/toolbar.dart

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ typedef WebVideoPickImpl = Future<String?> Function(
4949
typedef MediaPickSettingSelector = Future<MediaPickSetting?> Function(
5050
BuildContext context);
5151

52-
enum ToolbarAlignment { start, center, end }
53-
5452
// The default size of the icon of a button.
5553
const double kDefaultIconSize = 18;
5654

@@ -60,21 +58,21 @@ const double kIconButtonFactor = 1.77;
6058
class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
6159
const QuillToolbar({
6260
required this.children,
63-
this.toolBarHeight = 36,
64-
this.toolBarSectionSpacing,
65-
this.toolBarIconAlignment,
61+
this.toolbarHeight = 36,
62+
this.toolbarIconAlignment = WrapAlignment.center,
63+
this.toolbarSectionSpacing = 4,
64+
this.multiRowsDisplay = true,
6665
this.color,
6766
this.filePickImpl,
68-
this.multiRowsDisplay,
6967
this.locale,
7068
Key? key,
7169
}) : super(key: key);
7270

7371
factory QuillToolbar.basic({
7472
required QuillController controller,
7573
double toolbarIconSize = kDefaultIconSize,
76-
double toolBarSectionSpacing = 4,
77-
ToolbarAlignment toolBarIconAlignment = ToolbarAlignment.center,
74+
double toolbarSectionSpacing = 4,
75+
WrapAlignment toolbarIconAlignment = WrapAlignment.center,
7876
bool showBoldButton = true,
7977
bool showItalicButton = true,
8078
bool showSmallButton = false,
@@ -152,9 +150,9 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
152150

153151
return QuillToolbar(
154152
key: key,
155-
toolBarHeight: toolbarIconSize * 2,
156-
toolBarSectionSpacing: toolBarSectionSpacing,
157-
toolBarIconAlignment: toolBarIconAlignment,
153+
toolbarHeight: toolbarIconSize * 2,
154+
toolbarSectionSpacing: toolbarSectionSpacing,
155+
toolbarIconAlignment: toolbarIconAlignment,
158156
multiRowsDisplay: multiRowsDisplay,
159157
locale: locale,
160158
children: [
@@ -416,10 +414,10 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
416414
}
417415

418416
final List<Widget> children;
419-
final double toolBarHeight;
420-
final double? toolBarSectionSpacing;
421-
final ToolbarAlignment? toolBarIconAlignment;
422-
final bool? multiRowsDisplay;
417+
final double toolbarHeight;
418+
final double toolbarSectionSpacing;
419+
final WrapAlignment toolbarIconAlignment;
420+
final bool multiRowsDisplay;
423421

424422
/// The color of the toolbar.
425423
///
@@ -438,23 +436,17 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
438436
final Locale? locale;
439437

440438
@override
441-
Size get preferredSize => Size.fromHeight(toolBarHeight);
439+
Size get preferredSize => Size.fromHeight(toolbarHeight);
442440

443441
@override
444442
Widget build(BuildContext context) {
445443
return I18n(
446444
initialLocale: locale,
447-
child: multiRowsDisplay ?? true
445+
child: multiRowsDisplay
448446
? Wrap(
449-
alignment: (toolBarIconAlignment == ToolbarAlignment.start)
450-
? WrapAlignment.start
451-
: (toolBarIconAlignment == ToolbarAlignment.center)
452-
? WrapAlignment.center
453-
: (toolBarIconAlignment == ToolbarAlignment.end)
454-
? WrapAlignment.end
455-
: WrapAlignment.center,
447+
alignment: toolbarIconAlignment,
456448
runSpacing: 4,
457-
spacing: toolBarSectionSpacing ?? 4,
449+
spacing: toolbarSectionSpacing,
458450
children: children,
459451
)
460452
: Container(

0 commit comments

Comments
 (0)