Skip to content

Commit 6358677

Browse files
authored
Allow alignment of the toolbar icons to match WrapAlignment (singerdmx#462)
1 parent 278980c commit 6358677

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/src/widgets/toolbar.dart

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

52+
enum ToolbarAlignment{ start, center, end }
53+
5254
// The default size of the icon of a button.
5355
const double kDefaultIconSize = 18;
5456

@@ -60,6 +62,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
6062
required this.children,
6163
this.toolBarHeight = 36,
6264
this.toolBarSectionSpacing,
65+
this.toolBarIconAlignment,
6366
this.color,
6467
this.filePickImpl,
6568
this.multiRowsDisplay,
@@ -71,6 +74,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
7174
required QuillController controller,
7275
double toolbarIconSize = kDefaultIconSize,
7376
double toolBarSectionSpacing = 4,
77+
ToolbarAlignment toolBarIconAlignment = ToolbarAlignment.center,
7478
bool showBoldButton = true,
7579
bool showItalicButton = true,
7680
bool showSmallButton = false,
@@ -150,6 +154,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
150154
key: key,
151155
toolBarHeight: toolbarIconSize * 2,
152156
toolBarSectionSpacing: toolBarSectionSpacing,
157+
toolBarIconAlignment: toolBarIconAlignment,
153158
multiRowsDisplay: multiRowsDisplay,
154159
locale: locale,
155160
children: [
@@ -413,6 +418,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
413418
final List<Widget> children;
414419
final double toolBarHeight;
415420
final double? toolBarSectionSpacing;
421+
final ToolbarAlignment? toolBarIconAlignment;
416422
final bool? multiRowsDisplay;
417423

418424
/// The color of the toolbar.
@@ -440,7 +446,13 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
440446
initialLocale: locale,
441447
child: multiRowsDisplay ?? true
442448
? Wrap(
443-
alignment: WrapAlignment.center,
449+
alignment:
450+
(toolBarIconAlignment==ToolbarAlignment.start)
451+
? WrapAlignment.start
452+
:(toolBarIconAlignment==ToolbarAlignment.center)
453+
? WrapAlignment.center
454+
:(toolBarIconAlignment==ToolbarAlignment.end)
455+
? WrapAlignment.end : WrapAlignment.center,
444456
runSpacing: 4,
445457
spacing: toolBarSectionSpacing ?? 4,
446458
children: children,

0 commit comments

Comments
 (0)