7 -> 8
We have refactored a lot of the base code to allow you to customize everything you want, and it allows us to add new configurations very easily using inherited widgets without passing configurations all over the constructors everywhere which will be very hard to test, fix bugs, and maintain
Passing the controller
The controller code (should be the same)
QuillController _controller = QuillController.basic();Old code:
Column(
children: [
QuillToolbar.basic(controller: _controller),
Expanded(
child: QuillEditor.basic(
controller: _controller,
readOnly: false, // true for view only mode
),
)
],
)New code:
QuillProvider(
configurations: QuillConfigurations(
controller: _controller,
sharedConfigurations: const QuillSharedConfigurations(),
),
child: Column(
children: [
const QuillToolbar(),
Expanded(
child: QuillEditor.basic(
configurations: const QuillEditorConfigurations(
readOnly: false, // true for view only mode
),
),
)
],
),
)The QuillProvider is an inherited widget that allows you to pass configurations once and use them in the children of it. here we are passing the _controller once in the configurations of QuillProvider and the QuillToolbar and QuillEditor will get the QuillConfigurations internally, if it doesn't exist you will get an exception.
we also added the sharedConfigurations which allow you to configure shared things like the Local so you don't have to define them twice, we have removed those from the QuillToolbar and QuillEditor
Regarding The QuillToolbar buttons, we have renamed almost all the buttons, examples:
QuillHistorytoQuillToolbarHistoryButtonIndentButtontoQuillToolbarIndentButton
and they usually have two parameters, controller and options, for example the type for the buttons
QuillToolbarHistoryButtonhaveQuillToolbarHistoryButtonOptionsQuillToolbarIndentButtonhaveQuillToolbarIndentButtonOptionsQuillToolbarClearFormatButtonhaveQuillToolbarClearFormatButtonOptions
All the options have parent QuillToolbarBaseButtonOptions which have common things like
The QuillToolbarBaseButtonOptions is:
Example for the clear format button:
The base for extra options:
which usually share common things, it also add an extra property which was not exist, which is childBuilder which allow to rendering of custom widget based on the state of the button and the options it
the extraOptions usually contains the state variables and the events that you need to trigger like the onPressed, it also has the end context and the controller that will be used while the options has the custom controller for each button and it's nullable because there could be no custom controller so we will just use the global one
The
QuillToolbarandQuillToolbar.basic()factory constructor
since the basic factory constructor has more options than the original QuillToolbar which doesn't make much sense, at least to some developers, we have refactored the QuillToolbar.basic() to a different widget called the QuillToolbar and the QuillToolbar has been renamed to QuillBaseToolbar which is the base for QuillToolbar or any custom toolbar, sure you can create custom toolbar from scratch by just using the controller but if you want more support from the library use the QuillBaseToolbar
the children widgets of the new QuillToolbar and QuillEditor access to their configurations by another two inherited widgets since QuillToolbar and QuillEditor take the configuration class and provide them internally using QuillToolbarProvider and QuillEditorProvider however the QuillBaseToolbar has a little bit different configurations so it has a different provider called QuillBaseToolbarProvider and it also already provided by default
But there is one note:
If you are using the toolbar buttons like
QuillToolbarHistoryButton,QuillToolbarToggleStyleButtonsomewhere like the the custom toolbar (usingQuillBaseToolbaror any custom widget) then you must provide them withQuillToolbarProviderinherited widget, you don't have to do this if you are using theQuillToolbarsince it will be done for you
Example of a custom toolbar:
The
QuillEditorandQuillEditor.basic()
since the QuillEditor.basic() is a lighter version than the original QuillEditor since it has fewer required configurations we didn't change much, other than the configuration class, but we must inform you if you plan on sending pull request or you are a maintainer and when you add new property or change anything in QuillEditorConfigurations please regenerate the copyWith (using IDE extension or plugin) otherwise the QuilEditor.basic() will not apply some configurations
we have disabled the line numbers in the code block by default, you can enable them again using the following:
QuillCustomButton:
We have renamed the property icon to iconData to indicate it an icon data and not an icon widget
Using custom local for both
QuillEditorandQuillToolbar
We have added shared configurations property for shared things
Image size for all platforms
We have added new properties width, height, margin, alignment for all platforms other than mobile and web for the images for example
Other Improvements
You don't need anything to get this done, we have used const more when possible, removed unused events, flutter best practices, converted to stateless widgets when possible, and used better ways to listen for changes example:
instead of
we will use
We also minimized the number of rebuilds using more efficient logic and there is more.
More options
We have added more options in the extension package, for all the buttons, configurations, animations, enable and disable things
If you are facing any issues or questions feel free to ask us on GitHub issues
Last updated