@ -1,584 +1,370 @@
import ' package:flutter/material.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:i18n_extension/i18n_widget.dart ' ;
import ' ../../../flutter_quill.dart ' ;
import ' ../../../flutter_quill.dart ' ;
import ' ../../models/config/toolbar/base_configurations.dart ' ;
import ' ../../utils/extensions/build_context.dart ' ;
import ' ../../utils/extensions/build_context.dart ' ;
import ' buttons/arrow_indicated_list.dart ' ;
export ' ../../models/config/toolbar/buttons/base.dart ' ;
class QuillToolbar extends StatelessWidget {
export ' ../../models/config/toolbar/configurations.dart ' ;
export ' buttons/clear_format.dart ' ;
export ' buttons/color.dart ' ;
export ' buttons/custom_button.dart ' ;
export ' buttons/font_family.dart ' ;
export ' buttons/font_size.dart ' ;
export ' buttons/history.dart ' ;
export ' buttons/indent.dart ' ;
export ' buttons/link_style.dart ' ;
export ' buttons/link_style2.dart ' ;
export ' buttons/quill_icon.dart ' ;
export ' buttons/search/search.dart ' ;
export ' buttons/select_alignment.dart ' ;
export ' buttons/select_header_style.dart ' ;
export ' buttons/toggle_check_list.dart ' ;
export ' buttons/toggle_style.dart ' ;
typedef QuillToolbarChildrenBuilder = List < Widget > Function (
BuildContext context ,
) ;
class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
const QuillToolbar ( {
const QuillToolbar ( {
required this . childrenBuilder ,
super . key ,
this . axis = Axis . horizontal ,
this . configurations = const QuillToolbarConfigurations ( ) ,
/ / this . toolbarSize = kDefaultIconSize * 2 ,
} ) ;
this . toolbarSectionSpacing = kToolbarSectionSpacing ,
this . toolbarIconAlignment = WrapAlignment . center ,
this . toolbarIconCrossAlignment = WrapCrossAlignment . center ,
this . color ,
this . customButtons = const [ ] ,
this . sectionDividerColor ,
this . sectionDividerSpace ,
this . linkDialogAction ,
this . decoration ,
Key ? key ,
} ) : super ( key: key ) ;
factory QuillToolbar . basic ( {
double toolbarSectionSpacing = kToolbarSectionSpacing ,
WrapAlignment toolbarIconAlignment = WrapAlignment . center ,
WrapCrossAlignment toolbarIconCrossAlignment = WrapCrossAlignment . center ,
bool showDividers = true ,
bool showFontFamily = true ,
bool showFontSize = true ,
bool showBoldButton = true ,
bool showItalicButton = true ,
bool showSmallButton = false ,
bool showUnderLineButton = true ,
bool showStrikeThrough = true ,
bool showInlineCode = true ,
bool showColorButton = true ,
bool showBackgroundColorButton = true ,
bool showClearFormat = true ,
bool showAlignmentButtons = false ,
bool showLeftAlignment = true ,
bool showCenterAlignment = true ,
bool showRightAlignment = true ,
bool showJustifyAlignment = true ,
bool showHeaderStyle = true ,
bool showListNumbers = true ,
bool showListBullets = true ,
bool showListCheck = true ,
bool showCodeBlock = true ,
bool showQuote = true ,
bool showIndent = true ,
bool showLink = true ,
bool showUndo = true ,
bool showRedo = true ,
bool showDirection = false ,
bool showSearchButton = true ,
bool showSubscript = true ,
bool showSuperscript = true ,
List < QuillCustomButton > customButtons = const [ ] ,
/ / / The decoration to use for the toolbar .
Decoration ? decoration ,
/ / / Toolbar items to display for controls of embed blocks
List < EmbedButtonBuilder > ? embedButtons ,
/ / / The theme to use for the icons in the toolbar , uses type [ QuillIconTheme ]
QuillIconTheme ? iconTheme ,
/ / / The theme to use for the theming of the [ LinkDialog ( ) ] ,
/ / / shown when embedding an image , for example
QuillDialogTheme ? dialogTheme ,
/ / / Map of tooltips for toolbar buttons
/ / /
/ / / The example is :
/ / / ` ` ` dart
/ / / tooltips = < ToolbarButtons , String > {
/ / / ToolbarButtons . undo: ' Undo ' ,
/ / / ToolbarButtons . redo: ' Redo ' ,
/ / / }
/ / /
/ / / ` ` `
/ / /
/ / / To disable tooltips just pass empty map as well .
@ Deprecated ( ' This is deprecated and will no longer used. '
' to change the tooltips please pass them in the Quill toolbar button '
' configurations which exists in in the QuillProvider ' )
Map < ToolbarButtons , String > ? tooltips ,
/ / / The locale to use for the editor toolbar , defaults to system locale
/ / / More at https: / / github . com / singerdmx / flutter - quill # translation
Locale ? locale ,
/ / / The color of the toolbar
/ / / The configurations for the toolbar widget of flutter quill
Color ? color ,
final QuillToolbarConfigurations configurations ;
/ / / The color of the toolbar section divider
@ override
Color ? sectionDividerColor ,
Widget build ( BuildContext context ) {
final theEmbedButtons = configurations . embedButtons ;
/ / / The space occupied by toolbar divider
double ? sectionDividerSpace ,
Key ? key ,
} ) {
final isButtonGroupShown = [
final isButtonGroupShown = [
showFontFamily | |
configurations . showFontFamily | |
showFontSize | |
configurations . showFontSize | |
showBoldButton | |
configurations . showBoldButton | |
showItalicButton | |
configurations . showItalicButton | |
showSmallButton | |
configurations . showSmallButton | |
showUnderLineButton | |
configurations . showUnderLineButton | |
showStrikeThrough | |
configurations . showStrikeThrough | |
showInlineCode | |
configurations . showInlineCode | |
showColorButton | |
configurations . showColorButton | |
showBackgroundColorButton | |
configurations . showBackgroundColorButton | |
showClearFormat | |
configurations . showClearFormat | |
embedButtons ? . isNotEmpty = = true ,
theEmbedButtons ? . isNotEmpty = = true ,
showLeftAlignment | |
configurations . showLeftAlignment | |
showCenterAlignment | |
configurations . showCenterAlignment | |
showRightAlignment | |
configurations . showRightAlignment | |
showJustifyAlignment | |
configurations . showJustifyAlignment | |
showDirection ,
configurations . showDirection ,
showHeaderStyle ,
configurations . showHeaderStyle ,
showListNumbers | | showListBullets | | showListCheck | | showCodeBlock ,
configurations . showListNumbers | |
showQuote | | showIndent ,
configurations . showListBullets | |
showLink | | showSearchButton
configurations . showListCheck | |
configurations . showCodeBlock ,
configurations . showQuote | | configurations . showIndent ,
configurations . showLink | | configurations . showSearchButton
] ;
] ;
return QuillToolbar (
return QuillToolbarProvider (
key: key ,
toolbarConfigurations: configurations ,
color: color ,
child: QuillBaseToolbar (
decoration: decoration ,
configurations: QuillBaseToolbarConfigurations (
toolbarSectionSpacing: toolbarSectionSpacing ,
color: configurations . color ,
toolbarIconAlignment: toolbarIconAlignment ,
decoration: configurations . decoration ,
toolbarIconCrossAlignment: toolbarIconCrossAlignment ,
toolbarSectionSpacing: configurations . toolbarSectionSpacing ,
customButtons: customButtons ,
toolbarIconAlignment: configurations . toolbarIconAlignment ,
childrenBuilder: ( context ) {
toolbarIconCrossAlignment: configurations . toolbarIconCrossAlignment ,
final controller = context . requireQuillController ;
customButtons: configurations . customButtons ,
linkDialogAction: configurations . linkDialogAction ,
final toolbarConfigurations = context . requireQuillToolbarConfigurations ;
multiRowsDisplay: configurations . multiRowsDisplay ,
sectionDividerColor: configurations . sectionDividerColor ,
final globalIconSize =
axis: configurations . axis ,
toolbarConfigurations . buttonOptions . base . globalIconSize ;
sectionDividerSpace: configurations . sectionDividerSpace ,
toolbarSize: configurations . toolbarSize ,
final axis = toolbarConfigurations . axis ;
childrenBuilder: ( context ) {
final controller = context . requireQuillController ;
if ( tooltips ! = null ) {
throw UnsupportedError (
final toolbarConfigurations =
' This is deprecated and will no longer used. to change '
context . requireQuillToolbarConfigurations ;
' the tooltips please pass them in the Quill toolbar button '
' configurations which exists in in the QuillProvider ' ,
final globalIconSize =
) ;
toolbarConfigurations . buttonOptions . base . globalIconSize ;
}
final axis = toolbarConfigurations . axis ;
return [
final globalController = context . requireQuillController ;
if ( showUndo )
QuillToolbarHistoryButton (
return [
options: toolbarConfigurations . buttonOptions . undoHistory ,
if ( configurations . showUndo )
controller:
QuillToolbarHistoryButton (
toolbarConfigurations . buttonOptions . undoHistory . controller ? ?
options: toolbarConfigurations . buttonOptions . undoHistory ,
context . requireQuillController ,
controller: toolbarConfigurations
) ,
. buttonOptions . undoHistory . controller ? ?
if ( showRedo )
globalController ,
QuillToolbarHistoryButton (
) ,
options: toolbarConfigurations . buttonOptions . redoHistory ,
if ( configurations . showRedo )
controller:
QuillToolbarHistoryButton (
toolbarConfigurations . buttonOptions . redoHistory . controller ? ?
options: toolbarConfigurations . buttonOptions . redoHistory ,
context . requireQuillController ,
controller: toolbarConfigurations
) ,
. buttonOptions . redoHistory . controller ? ?
if ( showFontFamily )
globalController ,
QuillToolbarFontFamilyButton (
) ,
options: toolbarConfigurations . buttonOptions . fontFamily ,
if ( configurations . showFontFamily )
controller:
QuillToolbarFontFamilyButton (
toolbarConfigurations . buttonOptions . fontFamily . controller ? ?
options: toolbarConfigurations . buttonOptions . fontFamily ,
context . requireQuillController ,
controller: toolbarConfigurations
) ,
. buttonOptions . fontFamily . controller ? ?
if ( showFontSize )
globalController ,
QuillToolbarFontSizeButton (
) ,
options: toolbarConfigurations . buttonOptions . fontSize ,
if ( configurations . showFontSize )
controller:
QuillToolbarFontSizeButton (
toolbarConfigurations . buttonOptions . fontFamily . controller ? ?
options: toolbarConfigurations . buttonOptions . fontSize ,
context . requireQuillController ,
controller: toolbarConfigurations
) ,
. buttonOptions . fontFamily . controller ? ?
if ( showBoldButton )
globalController ,
QuillToolbarToggleStyleButton (
) ,
attribute: Attribute . bold ,
if ( configurations . showBoldButton )
options: toolbarConfigurations . buttonOptions . bold ,
QuillToolbarToggleStyleButton (
controller: toolbarConfigurations . buttonOptions . bold . controller ? ?
attribute: Attribute . bold ,
context . requireQuillController ,
options: toolbarConfigurations . buttonOptions . bold ,
) ,
controller:
if ( showSubscript )
toolbarConfigurations . buttonOptions . bold . controller ? ?
QuillToolbarToggleStyleButton (
globalController ,
attribute: Attribute . subscript ,
) ,
options: toolbarConfigurations . buttonOptions . subscript ,
if ( configurations . showSubscript )
controller:
QuillToolbarToggleStyleButton (
toolbarConfigurations . buttonOptions . subscript . controller ? ?
attribute: Attribute . subscript ,
context . requireQuillController ,
options: toolbarConfigurations . buttonOptions . subscript ,
) ,
controller: toolbarConfigurations
if ( showSuperscript )
. buttonOptions . subscript . controller ? ?
QuillToolbarToggleStyleButton (
globalController ,
attribute: Attribute . superscript ,
) ,
options: toolbarConfigurations . buttonOptions . superscript ,
if ( configurations . showSuperscript )
controller:
QuillToolbarToggleStyleButton (
toolbarConfigurations . buttonOptions . superscript . controller ? ?
attribute: Attribute . superscript ,
context . requireQuillController ,
options: toolbarConfigurations . buttonOptions . superscript ,
) ,
controller: toolbarConfigurations
if ( showItalicButton )
. buttonOptions . superscript . controller ? ?
QuillToolbarToggleStyleButton (
globalController ,
attribute: Attribute . italic ,
) ,
options: toolbarConfigurations . buttonOptions . italic ,
if ( configurations . showItalicButton )
controller:
QuillToolbarToggleStyleButton (
toolbarConfigurations . buttonOptions . italic . controller ? ?
attribute: Attribute . italic ,
context . requireQuillController ,
options: toolbarConfigurations . buttonOptions . italic ,
) ,
controller:
if ( showSmallButton )
toolbarConfigurations . buttonOptions . italic . controller ? ?
QuillToolbarToggleStyleButton (
globalController ,
attribute: Attribute . small ,
) ,
options: toolbarConfigurations . buttonOptions . small ,
if ( configurations . showSmallButton )
controller:
QuillToolbarToggleStyleButton (
toolbarConfigurations . buttonOptions . small . controller ? ?
attribute: Attribute . small ,
context . requireQuillController ,
options: toolbarConfigurations . buttonOptions . small ,
) ,
controller:
if ( showUnderLineButton )
toolbarConfigurations . buttonOptions . small . controller ? ?
QuillToolbarToggleStyleButton (
globalController ,
attribute: Attribute . underline ,
) ,
options: toolbarConfigurations . buttonOptions . underLine ,
if ( configurations . showUnderLineButton )
controller:
QuillToolbarToggleStyleButton (
toolbarConfigurations . buttonOptions . underLine . controller ? ?
attribute: Attribute . underline ,
context . requireQuillController ,
options: toolbarConfigurations . buttonOptions . underLine ,
) ,
controller: toolbarConfigurations
if ( showStrikeThrough )
. buttonOptions . underLine . controller ? ?
QuillToolbarToggleStyleButton (
globalController ,
attribute: Attribute . strikeThrough ,
) ,
options: toolbarConfigurations . buttonOptions . strikeThrough ,
if ( configurations . showStrikeThrough )
controller: toolbarConfigurations
QuillToolbarToggleStyleButton (
. buttonOptions . strikeThrough . controller ? ?
attribute: Attribute . strikeThrough ,
context . requireQuillController ,
options: toolbarConfigurations . buttonOptions . strikeThrough ,
) ,
controller: toolbarConfigurations
if ( showInlineCode )
. buttonOptions . strikeThrough . controller ? ?
QuillToolbarToggleStyleButton (
globalController ,
attribute: Attribute . inlineCode ,
) ,
options: toolbarConfigurations . buttonOptions . inlineCode ,
if ( configurations . showInlineCode )
controller:
QuillToolbarToggleStyleButton (
toolbarConfigurations . buttonOptions . inlineCode . controller ? ?
attribute: Attribute . inlineCode ,
context . requireQuillController ,
options: toolbarConfigurations . buttonOptions . inlineCode ,
) ,
controller: toolbarConfigurations
if ( showColorButton )
. buttonOptions . inlineCode . controller ? ?
QuillToolbarColorButton (
globalController ,
controller: controller ,
) ,
isBackground: false ,
if ( configurations . showColorButton )
options: toolbarConfigurations . buttonOptions . color ,
QuillToolbarColorButton (
) ,
controller: controller ,
if ( showBackgroundColorButton )
isBackground: false ,
QuillToolbarColorButton (
options: toolbarConfigurations . buttonOptions . color ,
options: toolbarConfigurations . buttonOptions . backgroundColor ,
) ,
controller: controller ,
if ( configurations . showBackgroundColorButton )
isBackground: true ,
QuillToolbarColorButton (
) ,
options: toolbarConfigurations . buttonOptions . backgroundColor ,
if ( showClearFormat )
controller: controller ,
QuillToolbarClearFormatButton (
isBackground: true ,
controller: controller ,
) ,
options: toolbarConfigurations . buttonOptions . clearFormat ,
if ( configurations . showClearFormat )
) ,
QuillToolbarClearFormatButton (
if ( embedButtons ! = null )
controller: controller ,
for ( final builder in embedButtons )
options: toolbarConfigurations . buttonOptions . clearFormat ,
builder ( controller , globalIconSize , iconTheme , dialogTheme ) ,
) ,
if ( showDividers & &
if ( theEmbedButtons ! = null )
isButtonGroupShown [ 0 ] & &
for ( final builder in theEmbedButtons )
( isButtonGroupShown [ 1 ] | |
builder ( controller , globalIconSize , configurations . iconTheme ,
isButtonGroupShown [ 2 ] | |
configurations . dialogTheme ) ,
isButtonGroupShown [ 3 ] | |
if ( configurations . showDividers & &
isButtonGroupShown [ 4 ] | |
isButtonGroupShown [ 0 ] & &
isButtonGroupShown [ 5 ] ) )
( isButtonGroupShown [ 1 ] | |
QuillToolbarDivider (
isButtonGroupShown [ 2 ] | |
axis ,
isButtonGroupShown [ 3 ] | |
color: sectionDividerColor ,
isButtonGroupShown [ 4 ] | |
space: sectionDividerSpace ,
isButtonGroupShown [ 5 ] ) )
) ,
QuillToolbarDivider (
if ( showAlignmentButtons )
axis ,
QuillToolbarSelectAlignmentButton (
color: configurations . sectionDividerColor ,
controller: controller ,
space: configurations . sectionDividerSpace ,
options:
) ,
toolbarConfigurations . buttonOptions . selectAlignmentButtons ,
if ( configurations . showAlignmentButtons )
/ / tooltips: Map . of ( buttonTooltips )
QuillToolbarSelectAlignmentButton (
/ / . . removeWhere ( ( key , value ) = > ! [
controller: controller ,
/ / ToolbarButtons . leftAlignment ,
options: toolbarConfigurations
/ / ToolbarButtons . centerAlignment ,
. buttonOptions . selectAlignmentButtons ,
/ / ToolbarButtons . rightAlignment ,
/ / tooltips: Map . of ( buttonTooltips )
/ / ToolbarButtons . justifyAlignment ,
/ / . . removeWhere ( ( key , value ) = > ! [
/ / ] . contains ( key ) ) ,
/ / ToolbarButtons . leftAlignment ,
showLeftAlignment: showLeftAlignment ,
/ / ToolbarButtons . centerAlignment ,
showCenterAlignment: showCenterAlignment ,
/ / ToolbarButtons . rightAlignment ,
showRightAlignment: showRightAlignment ,
/ / ToolbarButtons . justifyAlignment ,
showJustifyAlignment: showJustifyAlignment ,
/ / ] . contains ( key ) ) ,
) ,
showLeftAlignment: configurations . showLeftAlignment ,
if ( showDirection )
showCenterAlignment: configurations . showCenterAlignment ,
QuillToolbarToggleStyleButton (
showRightAlignment: configurations . showRightAlignment ,
attribute: Attribute . rtl ,
showJustifyAlignment: configurations . showJustifyAlignment ,
options: toolbarConfigurations . buttonOptions . direction ,
) ,
controller:
if ( configurations . showDirection )
toolbarConfigurations . buttonOptions . direction . controller ? ?
QuillToolbarToggleStyleButton (
context . requireQuillController ,
attribute: Attribute . rtl ,
) ,
options: toolbarConfigurations . buttonOptions . direction ,
if ( showDividers & &
controller: toolbarConfigurations
isButtonGroupShown [ 1 ] & &
. buttonOptions . direction . controller ? ?
( isButtonGroupShown [ 2 ] | |
isButtonGroupShown [ 3 ] | |
isButtonGroupShown [ 4 ] | |
isButtonGroupShown [ 5 ] ) )
QuillToolbarDivider (
axis ,
color: sectionDividerColor ,
space: sectionDividerSpace ,
) ,
if ( showHeaderStyle )
QuillToolbarSelectHeaderStyleButtons (
controller: controller ,
options:
toolbarConfigurations . buttonOptions . selectHeaderStyleButtons ,
/ / tooltip: buttonTooltips [ ToolbarButtons . headerStyle ] ,
/ / axis: axis ,
/ / iconSize: toolbarIconSize ,
/ / iconTheme: iconTheme ,
/ / afterButtonPressed: afterButtonPressed ,
) ,
if ( showDividers & &
showHeaderStyle & &
isButtonGroupShown [ 2 ] & &
( isButtonGroupShown [ 3 ] | |
isButtonGroupShown [ 4 ] | |
isButtonGroupShown [ 5 ] ) )
QuillToolbarDivider (
axis ,
color: sectionDividerColor ,
space: sectionDividerSpace ,
) ,
if ( showListNumbers )
QuillToolbarToggleStyleButton (
attribute: Attribute . ol ,
options: toolbarConfigurations . buttonOptions . listNumbers ,
controller:
toolbarConfigurations . buttonOptions . listNumbers . controller ? ?
context . requireQuillController ,
) ,
if ( showListBullets )
QuillToolbarToggleStyleButton (
attribute: Attribute . ul ,
options: toolbarConfigurations . buttonOptions . listBullets ,
controller:
toolbarConfigurations . buttonOptions . listBullets . controller ? ?
context . requireQuillController ,
) ,
if ( showListCheck )
QuillToolbarToggleCheckListButton (
options: toolbarConfigurations . buttonOptions . toggleCheckList ,
controller: toolbarConfigurations
. buttonOptions . toggleCheckList . controller ? ?
context . requireQuillController ,
) ,
if ( showCodeBlock )
QuillToolbarToggleStyleButton (
attribute: Attribute . codeBlock ,
options: toolbarConfigurations . buttonOptions . codeBlock ,
controller:
toolbarConfigurations . buttonOptions . codeBlock . controller ? ?
context . requireQuillController ,
context . requireQuillController ,
) ,
) ,
if ( showDividers & &
if ( configurations . showDividers & &
isButtonGroupShown [ 3 ] & &
isButtonGroupShown [ 1 ] & &
( isButtonGroupShown [ 4 ] | | isButtonGroupShown [ 5 ] ) )
( isButtonGroupShown [ 2 ] | |
QuillToolbarDivider ( axis ,
isButtonGroupShown [ 3 ] | |
color: sectionDividerColor , space: sectionDividerSpace ) ,
isButtonGroupShown [ 4 ] | |
if ( showQuote )
isButtonGroupShown [ 5 ] ) )
QuillToolbarToggleStyleButton (
QuillToolbarDivider (
options: toolbarConfigurations . buttonOptions . quote ,
axis ,
controller:
color: configurations . sectionDividerColor ,
toolbarConfigurations . buttonOptions . quote . controller ? ?
space: configurations . sectionDividerSpace ,
context . requireQuillController ,
) ,
attribute: Attribute . blockQuote ,
if ( configurations . showHeaderStyle )
) ,
QuillToolbarSelectHeaderStyleButtons (
if ( showIndent )
controller: controller ,
QuillToolbarIndentButton (
options: toolbarConfigurations
controller: toolbarConfigurations
. buttonOptions . selectHeaderStyleButtons ,
. buttonOptions . indentIncrease . controller ? ?
) ,
context . requireQuillController ,
if ( configurations . showDividers & &
isIncrease: true ,
configurations . showHeaderStyle & &
options: toolbarConfigurations . buttonOptions . indentIncrease ,
isButtonGroupShown [ 2 ] & &
) ,
( isButtonGroupShown [ 3 ] | |
if ( showIndent )
isButtonGroupShown [ 4 ] | |
QuillToolbarIndentButton (
isButtonGroupShown [ 5 ] ) )
controller: toolbarConfigurations
QuillToolbarDivider (
. buttonOptions . indentDecrease . controller ? ?
axis ,
context . requireQuillController ,
color: configurations . sectionDividerColor ,
isIncrease: false ,
space: configurations . sectionDividerSpace ,
options: toolbarConfigurations . buttonOptions . indentDecrease ,
) ,
) ,
if ( configurations . showListNumbers )
if ( showDividers & & isButtonGroupShown [ 4 ] & & isButtonGroupShown [ 5 ] )
QuillToolbarToggleStyleButton (
QuillToolbarDivider ( axis ,
attribute: Attribute . ol ,
color: sectionDividerColor , space: sectionDividerSpace ) ,
options: toolbarConfigurations . buttonOptions . listNumbers ,
if ( showLink )
controller: toolbarConfigurations
QuillToolbarLinkStyleButton (
. buttonOptions . listNumbers . controller ? ?
controller: controller ,
globalController ,
options: toolbarConfigurations . buttonOptions . linkStyle ,
) ,
) ,
if ( configurations . showListBullets )
if ( showSearchButton )
QuillToolbarToggleStyleButton (
QuillToolbarSearchButton (
attribute: Attribute . ul ,
controller: controller ,
options: toolbarConfigurations . buttonOptions . listBullets ,
options: toolbarConfigurations . buttonOptions . search ,
controller: toolbarConfigurations
) ,
. buttonOptions . listBullets . controller ? ?
if ( customButtons . isNotEmpty )
globalController ,
if ( showDividers )
) ,
QuillToolbarDivider (
if ( configurations . showListCheck )
axis ,
QuillToolbarToggleCheckListButton (
color: sectionDividerColor ,
options: toolbarConfigurations . buttonOptions . toggleCheckList ,
space: sectionDividerSpace ,
controller: toolbarConfigurations
) ,
. buttonOptions . toggleCheckList . controller ? ?
for ( final customButton in customButtons )
globalController ,
if ( customButton . child ! = null ) . . . [
) ,
InkWell (
if ( configurations . showCodeBlock )
onTap: customButton . onTap ,
QuillToolbarToggleStyleButton (
child: customButton . child ,
attribute: Attribute . codeBlock ,
) ,
options: toolbarConfigurations . buttonOptions . codeBlock ,
] else . . . [
controller: toolbarConfigurations
CustomButton (
. buttonOptions . codeBlock . controller ? ?
onPressed: customButton . onTap ,
globalController ,
icon: customButton . iconData ? ?
) ,
context . quillToolbarBaseButtonOptions ? . iconData ,
if ( configurations . showDividers & &
iconColor: customButton . iconColor ,
isButtonGroupShown [ 3 ] & &
iconSize: customButton . iconSize ? ? globalIconSize ,
( isButtonGroupShown [ 4 ] | | isButtonGroupShown [ 5 ] ) )
iconTheme: iconTheme ? ?
QuillToolbarDivider (
context . quillToolbarBaseButtonOptions ? . iconTheme ,
axis ,
afterButtonPressed: customButton . afterButtonPressed ? ?
color: configurations . sectionDividerColor ,
context . quillToolbarBaseButtonOptions ? . afterButtonPressed ,
space: configurations . sectionDividerSpace ,
tooltip: customButton . tooltip ? ?
) ,
context . quillToolbarBaseButtonOptions ? . tooltip ,
if ( configurations . showQuote )
) ,
QuillToolbarToggleStyleButton (
] ,
options: toolbarConfigurations . buttonOptions . quote ,
] ;
controller:
} ,
toolbarConfigurations . buttonOptions . quote . controller ? ?
) ;
globalController ,
}
attribute: Attribute . blockQuote ,
) ,
final QuillToolbarChildrenBuilder childrenBuilder ;
if ( configurations . showIndent )
final Axis axis ;
QuillToolbarIndentButton (
final double toolbarSectionSpacing ;
controller: toolbarConfigurations
final WrapAlignment toolbarIconAlignment ;
. buttonOptions . indentIncrease . controller ? ?
final WrapCrossAlignment toolbarIconCrossAlignment ;
globalController ,
isIncrease: true ,
/ / Overrides the action in the _LinkDialog widget
options: toolbarConfigurations . buttonOptions . indentIncrease ,
final LinkDialogAction ? linkDialogAction ;
) ,
if ( configurations . showIndent )
/ / / The color of the toolbar .
QuillToolbarIndentButton (
/ / /
controller: toolbarConfigurations
/ / / Defaults to [ ThemeData . canvasColor ] of the current [ Theme ] if no color
. buttonOptions . indentDecrease . controller ? ?
/ / / is given .
globalController ,
final Color ? color ;
isIncrease: false ,
options: toolbarConfigurations . buttonOptions . indentDecrease ,
/ / / List of custom buttons
) ,
final List < QuillCustomButton > customButtons ;
if ( configurations . showDividers & &
isButtonGroupShown [ 4 ] & &
/ / / The color to use when painting the toolbar section divider .
isButtonGroupShown [ 5 ] )
/ / /
QuillToolbarDivider (
/ / / If this is null , then the [ DividerThemeData . color ] is used . If that is
axis ,
/ / / also null , then [ ThemeData . dividerColor ] is used .
color: configurations . sectionDividerColor ,
final Color ? sectionDividerColor ;
space: configurations . sectionDividerSpace ,
) ,
/ / / The space occupied by toolbar section divider .
if ( configurations . showLink )
final double ? sectionDividerSpace ;
QuillToolbarLinkStyleButton (
controller: controller ,
/ / / The decoration to use for the toolbar .
options: toolbarConfigurations . buttonOptions . linkStyle ,
final Decoration ? decoration ;
) ,
if ( configurations . showSearchButton )
/ / We can ' t get the modified [toolbarSize] by the developer
QuillToolbarSearchButton (
/ / but I tested the [ QuillToolbar ] on the [ appBar ] and I didn ' t notice
controller: controller ,
/ / a difference no matter what the value is so I will leave it to the
options: toolbarConfigurations . buttonOptions . search ,
/ / default
) ,
@ override
if ( configurations . customButtons . isNotEmpty )
Size get preferredSize = > axis = = Axis . horizontal
if ( configurations . showDividers )
? const Size . fromHeight ( defaultToolbarSize )
QuillToolbarDivider (
: const Size . fromWidth ( defaultToolbarSize ) ;
axis ,
color: configurations . sectionDividerColor ,
@ override
space: configurations . sectionDividerSpace ,
Widget build ( BuildContext context ) {
final toolbarConfigurations = context . requireQuillToolbarConfigurations ;
final toolbarSize = toolbarConfigurations . toolbarSize ;
return I18n (
initialLocale: context . quillSharedConfigurations ? . locale ,
child: ( toolbarConfigurations . multiRowsDisplay )
? Wrap (
direction: axis ,
alignment: toolbarIconAlignment ,
crossAxisAlignment: toolbarIconCrossAlignment ,
runSpacing: 4 ,
spacing: toolbarSectionSpacing ,
children: childrenBuilder ( context ) ,
)
: Container (
decoration: decoration ? ?
BoxDecoration (
color: color ? ? Theme . of ( context ) . canvasColor ,
) ,
) ,
constraints: BoxConstraints . tightFor (
for ( final customButton in configurations . customButtons )
height: axis = = Axis . horizontal ? toolbarSize : null ,
if ( customButton . child ! = null ) . . . [
width: axis = = Axis . vertical ? toolbarSize : null ,
InkWell (
) ,
onTap: customButton . onTap ,
child: QuillToolbarArrowIndicatedButtonList (
child: customButton . child ,
axis: axis ,
) ,
buttons: childrenBuilder ( context ) ,
] else . . . [
) ,
CustomButton (
) ,
onPressed: customButton . onTap ,
icon: customButton . iconData ? ?
context . quillToolbarBaseButtonOptions ? . iconData ,
iconColor: customButton . iconColor ,
iconSize: customButton . iconSize ? ? globalIconSize ,
iconTheme: configurations . iconTheme ? ?
context . quillToolbarBaseButtonOptions ? . iconTheme ,
afterButtonPressed: customButton . afterButtonPressed ? ?
context
. quillToolbarBaseButtonOptions ? . afterButtonPressed ,
tooltip: customButton . tooltip ? ?
context . quillToolbarBaseButtonOptions ? . tooltip ,
) ,
] ,
] ;
} ,
) ,
) ,
) ;
) ;
}
}
}
}
/ / / The divider which is used for separation of buttons in the toolbar .
/ / /
/ / / It can be used outside of this package , for example when user does not use
/ / / [ QuillToolbar . basic ] and compose toolbar ' s children on its own.
class QuillToolbarDivider extends StatelessWidget {
const QuillToolbarDivider (
this . axis , {
super . key ,
this . color ,
this . space ,
} ) ;
/ / / Provides a horizontal divider for vertical toolbar .
const QuillToolbarDivider . horizontal ( { Color ? color , double ? space } )
: this ( Axis . horizontal , color: color , space: space ) ;
/ / / Provides a horizontal divider for horizontal toolbar .
const QuillToolbarDivider . vertical ( { Color ? color , double ? space } )
: this ( Axis . vertical , color: color , space: space ) ;
/ / / The axis along which the toolbar is .
final Axis axis ;
/ / / The color to use when painting this divider ' s line.
final Color ? color ;
/ / / The divider ' s space (width or height) depending of [axis].
final double ? space ;
@ override
Widget build ( BuildContext context ) {
/ / Vertical toolbar requires horizontal divider , and vice versa
return axis = = Axis . vertical
? Divider (
height: space ,
color: color ,
indent: 12 ,
endIndent: 12 ,
)
: VerticalDivider (
width: space ,
color: color ,
indent: 12 ,
endIndent: 12 ,
) ;
}
}