Make toolbar optional params not nullable

pull/466/head
Cheryl 3 years ago
parent 0dedb1c805
commit 4cce50a6f9
  1. 42
      lib/src/widgets/toolbar.dart

@ -49,8 +49,6 @@ typedef WebVideoPickImpl = Future<String?> Function(
typedef MediaPickSettingSelector = Future<MediaPickSetting?> Function( typedef MediaPickSettingSelector = Future<MediaPickSetting?> Function(
BuildContext context); BuildContext context);
enum ToolbarAlignment { start, center, end }
// The default size of the icon of a button. // The default size of the icon of a button.
const double kDefaultIconSize = 18; const double kDefaultIconSize = 18;
@ -60,12 +58,12 @@ const double kIconButtonFactor = 1.77;
class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
const QuillToolbar({ const QuillToolbar({
required this.children, required this.children,
this.toolBarHeight = 36, this.toolbarHeight = 36,
this.toolBarSectionSpacing, this.toolbarIconAlignment = WrapAlignment.center,
this.toolBarIconAlignment, this.toolbarSectionSpacing = 4,
this.multiRowsDisplay = true,
this.color, this.color,
this.filePickImpl, this.filePickImpl,
this.multiRowsDisplay,
this.locale, this.locale,
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
@ -73,8 +71,8 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
factory QuillToolbar.basic({ factory QuillToolbar.basic({
required QuillController controller, required QuillController controller,
double toolbarIconSize = kDefaultIconSize, double toolbarIconSize = kDefaultIconSize,
double toolBarSectionSpacing = 4, double toolbarSectionSpacing = 4,
ToolbarAlignment toolBarIconAlignment = ToolbarAlignment.center, WrapAlignment toolbarIconAlignment = WrapAlignment.center,
bool showBoldButton = true, bool showBoldButton = true,
bool showItalicButton = true, bool showItalicButton = true,
bool showSmallButton = false, bool showSmallButton = false,
@ -152,9 +150,9 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
return QuillToolbar( return QuillToolbar(
key: key, key: key,
toolBarHeight: toolbarIconSize * 2, toolbarHeight: toolbarIconSize * 2,
toolBarSectionSpacing: toolBarSectionSpacing, toolbarSectionSpacing: toolbarSectionSpacing,
toolBarIconAlignment: toolBarIconAlignment, toolbarIconAlignment: toolbarIconAlignment,
multiRowsDisplay: multiRowsDisplay, multiRowsDisplay: multiRowsDisplay,
locale: locale, locale: locale,
children: [ children: [
@ -416,10 +414,10 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
} }
final List<Widget> children; final List<Widget> children;
final double toolBarHeight; final double toolbarHeight;
final double? toolBarSectionSpacing; final double toolbarSectionSpacing;
final ToolbarAlignment? toolBarIconAlignment; final WrapAlignment toolbarIconAlignment;
final bool? multiRowsDisplay; final bool multiRowsDisplay;
/// The color of the toolbar. /// The color of the toolbar.
/// ///
@ -438,23 +436,17 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
final Locale? locale; final Locale? locale;
@override @override
Size get preferredSize => Size.fromHeight(toolBarHeight); Size get preferredSize => Size.fromHeight(toolbarHeight);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return I18n( return I18n(
initialLocale: locale, initialLocale: locale,
child: multiRowsDisplay ?? true child: multiRowsDisplay
? Wrap( ? Wrap(
alignment: (toolBarIconAlignment == ToolbarAlignment.start) alignment: toolbarIconAlignment,
? WrapAlignment.start
: (toolBarIconAlignment == ToolbarAlignment.center)
? WrapAlignment.center
: (toolBarIconAlignment == ToolbarAlignment.end)
? WrapAlignment.end
: WrapAlignment.center,
runSpacing: 4, runSpacing: 4,
spacing: toolBarSectionSpacing ?? 4, spacing: toolbarSectionSpacing,
children: children, children: children,
) )
: Container( : Container(

Loading…
Cancel
Save