@ -1,6 +1,8 @@
import ' package:flutter/material.dart ' ;
import ' ../controller/quill_controller.dart ' ;
import ' ../document/attribute.dart ' ;
import ' ../document/document.dart ' ;
import ' base_toolbar.dart ' ;
import ' buttons/alignment/select_alignment_buttons.dart ' ;
import ' buttons/arrow_indicated_list_button.dart ' ;
@ -9,13 +11,37 @@ import 'simple_toolbar_provider.dart';
class QuillSimpleToolbar extends StatelessWidget
implements PreferredSizeWidget {
const QuillSimpleToolbar ( {
required this . configurations ,
factory QuillSimpleToolbar ( {
required QuillSimpleToolbarConfigurations ? configurations ,
QuillController ? controller ,
Key ? key ,
} ) {
/ / ignore: deprecated_member_use_from_same_package
controller ? ? = configurations ? . controller ;
assert ( controller ! = null ,
' controller required. Provide controller directly (preferred) or indirectly through configurations (not recommended - will be removed in future versions). ' ) ;
controller ? ? = QuillController (
document: Document ( ) ,
selection: const TextSelection . collapsed ( offset: 0 ) ) ;
/ /
controller . toolbarConfigurations = configurations ;
/ /
return QuillSimpleToolbar . _ (
controller: controller ,
key: key ,
) ;
}
const QuillSimpleToolbar . _ ( {
required this . controller ,
super . key ,
} ) ;
final QuillController controller ;
/ / / The configurations for the toolbar widget of flutter quill
final QuillSimpleToolbarConfigurations configurations ;
QuillSimpleToolbarConfigurations get configurations = >
controller . toolbarConfigurations ;
double get _toolbarSize = > configurations . toolbarSize * 1.4 ;
@ -30,7 +56,6 @@ class QuillSimpleToolbar extends StatelessWidget
final globalIconSize = toolbarConfigurations . buttonOptions . base . iconSize ;
final axis = toolbarConfigurations . axis ;
final globalController = configurations . controller ;
final divider = SizedBox (
height: _toolbarSize ,
@ -46,93 +71,93 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarHistoryButton (
isUndo: true ,
options: toolbarConfigurations . buttonOptions . undoHistory ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showRedo )
QuillToolbarHistoryButton (
isUndo: false ,
options: toolbarConfigurations . buttonOptions . redoHistory ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showFontFamily )
QuillToolbarFontFamilyButton (
options: toolbarConfigurations . buttonOptions . fontFamily ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showFontSize )
QuillToolbarFontSizeButton (
options: toolbarConfigurations . buttonOptions . fontSize ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showBoldButton )
QuillToolbarToggleStyleButton (
attribute: Attribute . bold ,
options: toolbarConfigurations . buttonOptions . bold ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showItalicButton )
QuillToolbarToggleStyleButton (
attribute: Attribute . italic ,
options: toolbarConfigurations . buttonOptions . italic ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showUnderLineButton )
QuillToolbarToggleStyleButton (
attribute: Attribute . underline ,
options: toolbarConfigurations . buttonOptions . underLine ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showStrikeThrough )
QuillToolbarToggleStyleButton (
attribute: Attribute . strikeThrough ,
options: toolbarConfigurations . buttonOptions . strikeThrough ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showInlineCode )
QuillToolbarToggleStyleButton (
attribute: Attribute . inlineCode ,
options: toolbarConfigurations . buttonOptions . inlineCode ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showSubscript )
QuillToolbarToggleStyleButton (
attribute: Attribute . subscript ,
options: toolbarConfigurations . buttonOptions . subscript ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showSuperscript )
QuillToolbarToggleStyleButton (
attribute: Attribute . superscript ,
options: toolbarConfigurations . buttonOptions . superscript ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showSmallButton )
QuillToolbarToggleStyleButton (
attribute: Attribute . small ,
options: toolbarConfigurations . buttonOptions . small ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showColorButton )
QuillToolbarColorButton (
controller: globalC ontroller,
controller: c ontroller,
isBackground: false ,
options: toolbarConfigurations . buttonOptions . color ,
) ,
if ( configurations . showBackgroundColorButton )
QuillToolbarColorButton (
options: toolbarConfigurations . buttonOptions . backgroundColor ,
controller: globalC ontroller,
controller: c ontroller,
isBackground: true ,
) ,
if ( configurations . showClearFormat )
QuillToolbarClearFormatButton (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations . buttonOptions . clearFormat ,
) ,
if ( theEmbedButtons ! = null )
for ( final builder in theEmbedButtons )
builder (
globalC ontroller,
c ontroller,
globalIconSize ? ? kDefaultIconSize ,
context . quillToolbarBaseButtonOptions ? . iconTheme ,
configurations . dialogTheme ) ,
@ -140,7 +165,7 @@ class QuillSimpleToolbar extends StatelessWidget
[
if ( configurations . showAlignmentButtons )
QuillToolbarSelectAlignmentButtons (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations
. buttonOptions . selectAlignmentButtons
. copyWith (
@ -154,26 +179,26 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
attribute: Attribute . rtl ,
options: toolbarConfigurations . buttonOptions . direction ,
controller: globalC ontroller,
controller: c ontroller,
) ,
] ,
[
if ( configurations . showLineHeightButton )
QuillToolbarSelectLineHeightStyleDropdownButton (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations
. buttonOptions . selectLineHeightStyleDropdownButton ,
) ,
if ( configurations . showHeaderStyle ) . . . [
if ( configurations . headerStyleType . isOriginal )
QuillToolbarSelectHeaderStyleDropdownButton (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations
. buttonOptions . selectHeaderStyleDropdownButton ,
)
else
QuillToolbarSelectHeaderStyleButtons (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations
. buttonOptions . selectHeaderStyleButtons ,
) ,
@ -184,42 +209,42 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
attribute: Attribute . ol ,
options: toolbarConfigurations . buttonOptions . listNumbers ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showListBullets )
QuillToolbarToggleStyleButton (
attribute: Attribute . ul ,
options: toolbarConfigurations . buttonOptions . listBullets ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showListCheck )
QuillToolbarToggleCheckListButton (
options: toolbarConfigurations . buttonOptions . toggleCheckList ,
controller: globalC ontroller,
controller: c ontroller,
) ,
if ( configurations . showCodeBlock )
QuillToolbarToggleStyleButton (
attribute: Attribute . codeBlock ,
options: toolbarConfigurations . buttonOptions . codeBlock ,
controller: globalC ontroller,
controller: c ontroller,
) ,
] ,
[
if ( configurations . showQuote )
QuillToolbarToggleStyleButton (
options: toolbarConfigurations . buttonOptions . quote ,
controller: globalC ontroller,
controller: c ontroller,
attribute: Attribute . blockQuote ,
) ,
if ( configurations . showIndent )
QuillToolbarIndentButton (
controller: globalC ontroller,
controller: c ontroller,
isIncrease: true ,
options: toolbarConfigurations . buttonOptions . indentIncrease ,
) ,
if ( configurations . showIndent )
QuillToolbarIndentButton (
controller: globalC ontroller,
controller: c ontroller,
isIncrease: false ,
options: toolbarConfigurations . buttonOptions . indentDecrease ,
) ,
@ -228,40 +253,40 @@ class QuillSimpleToolbar extends StatelessWidget
if ( configurations . showLink )
toolbarConfigurations . linkStyleType . isOriginal
? QuillToolbarLinkStyleButton (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations . buttonOptions . linkStyle ,
)
: QuillToolbarLinkStyleButton2 (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations . buttonOptions . linkStyle2 ,
) ,
if ( configurations . showSearchButton )
switch ( configurations . searchButtonType ) {
SearchButtonType . legacy = > QuillToolbarLegacySearchButton (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations . buttonOptions . search ,
) ,
SearchButtonType . modern = > QuillToolbarSearchButton (
controller: globalC ontroller,
controller: c ontroller,
options: toolbarConfigurations . buttonOptions . search ,
) ,
} ,
if ( configurations . showClipboardCut )
QuillToolbarClipboardButton (
options: toolbarConfigurations . buttonOptions . clipboardCut ,
controller: globalC ontroller,
controller: c ontroller,
clipboardAction: ClipboardAction . cut ,
) ,
if ( configurations . showClipboardCopy )
QuillToolbarClipboardButton (
options: toolbarConfigurations . buttonOptions . clipboardCopy ,
controller: globalC ontroller,
controller: c ontroller,
clipboardAction: ClipboardAction . copy ,
) ,
if ( configurations . showClipboardPaste )
QuillToolbarClipboardButton (
options: toolbarConfigurations . buttonOptions . clipboardPaste ,
controller: globalC ontroller,
controller: c ontroller,
clipboardAction: ClipboardAction . paste ,
) ,
] ,
@ -269,7 +294,7 @@ class QuillSimpleToolbar extends StatelessWidget
for ( final customButton in configurations . customButtons )
QuillToolbarCustomButton (
options: customButton ,
controller: globalC ontroller,
controller: c ontroller,
) ,
] ,
] ;