Deprecate controller access through configurations

pull/2078/head
AtlasAutocode 8 months ago
parent d354ab21f9
commit 06d09b196a
  1. 16
      example/lib/screens/quill/quill_screen.dart
  2. 4
      lib/src/controller/provider.dart
  3. 16
      lib/src/controller/quill_controller.dart
  4. 12
      lib/src/controller/quill_controller_configurations.dart
  5. 3
      lib/src/editor/config/editor_configurations.dart
  6. 1
      lib/src/editor/editor.dart
  7. 1
      lib/src/editor/provider.dart
  8. 1
      lib/src/editor/raw_editor/config/raw_editor_configurations.dart
  9. 5
      lib/src/editor/raw_editor/raw_editor.dart
  10. 2
      lib/src/editor/raw_editor/raw_editor_state.dart
  11. 1
      lib/src/toolbar/config/simple_toolbar_configurations.dart
  12. 7
      lib/src/toolbar/simple_toolbar.dart

@ -34,17 +34,7 @@ class QuillScreen extends StatefulWidget {
class _QuillScreenState extends State<QuillScreen> {
/// Instantiate the controller
final _controller = QuillController.basic(
configurations: const QuillControllerConfigurations(
/// Set default editor configuration (Recommended if configuration will never change, but can be overridden when editor is built)
editorConfigurations:
QuillEditorConfigurations(padding: EdgeInsets.all(5)),
/// Set default toolbar configuration (Recommended if configuration will never change, but can be overridden when toolbar is built)
toolbarConfigurations: QuillSimpleToolbarConfigurations(
searchButtonType: SearchButtonType.modern)),
);
final _controller = QuillController.basic();
final _editorFocusNode = FocusNode();
final _editorScrollController = ScrollController();
var _isReadOnly = false;
@ -113,10 +103,6 @@ class _QuillScreenState extends State<QuillScreen> {
return Expanded(
child: MyQuillEditor(
controller: _controller,
/// configurations parameter:
/// Optional: if not provided will use the configuration set when the controller was instantiated.
/// Override: Provide parameter here to override the default configuration - useful if configuration will change.
configurations: QuillEditorConfigurations(
sharedConfigurations: _sharedConfigurations,
),

@ -6,12 +6,16 @@ import 'quill_controller.dart';
extension QuillControllerExt on BuildContext {
QuillController? get quilController {
// ignore: deprecated_member_use_from_same_package
return quillSimpleToolbarConfigurations?.controller ??
// ignore: deprecated_member_use_from_same_package
quillEditorConfigurations?.controller;
}
QuillController get requireQuillController {
// ignore: deprecated_member_use_from_same_package
return quillSimpleToolbarConfigurations?.controller ??
// ignore: deprecated_member_use_from_same_package
quillEditorConfigurations?.controller ??
(throw ArgumentError(
'The quill provider is required, you must only call requireQuillController inside the QuillToolbar and QuillEditor'));

@ -55,27 +55,19 @@ class QuillController extends ChangeNotifier {
/// Editor configurations
///
/// Global default can be set in QuillControllerConfigurations.
/// Can be overridden by setting in QuillEditor ctor.
/// Fail safe: returns a default editor configuration.
/// Caches configuration set in QuillEditor ctor.
QuillEditorConfigurations? _editorConfigurations;
QuillEditorConfigurations get editorConfigurations =>
_editorConfigurations ??
configurations.editorConfigurations ??
const QuillEditorConfigurations();
_editorConfigurations ?? const QuillEditorConfigurations();
set editorConfigurations(QuillEditorConfigurations? value) =>
_editorConfigurations = value;
/// Toolbar configurations
///
/// Global default can be set in QuillControllerConfigurations.
/// Can be overridden by setting in QuillSimpleToolbar ctor.
/// Fail safe: returns a default toolbar configuration.
/// Caches configuration set in QuillSimpleToolbar ctor.
QuillSimpleToolbarConfigurations? _toolbarConfigurations;
QuillSimpleToolbarConfigurations get toolbarConfigurations =>
_toolbarConfigurations ??
configurations.toolbarConfigurations ??
const QuillSimpleToolbarConfigurations();
_toolbarConfigurations ?? const QuillSimpleToolbarConfigurations();
set toolbarConfigurations(QuillSimpleToolbarConfigurations? value) =>
_toolbarConfigurations = value;

@ -1,19 +1,17 @@
import '../editor/config/editor_configurations.dart'
show QuillEditorConfigurations;
import '../toolbar/config/simple_toolbar_configurations.dart';
class QuillControllerConfigurations {
const QuillControllerConfigurations(
{this.editorConfigurations,
this.toolbarConfigurations,
{@Deprecated(
'This parameter is not used and will be removed in future versions.')
this.editorConfigurations,
this.onClipboardPaste,
this.requireScriptFontFeatures = false});
/// Provides central access to editor configurations required for controller actions
///
/// Future: will be changed to 'required final'
@Deprecated(
'This parameter is not used and will be removed in future versions.')
final QuillEditorConfigurations? editorConfigurations;
final QuillSimpleToolbarConfigurations? toolbarConfigurations;
/// Callback when the user pastes and data has not already been processed
///

@ -88,6 +88,7 @@ class QuillEditorConfigurations extends Equatable {
final QuillSharedConfigurations sharedConfigurations;
@Deprecated('controller will be removed in future versions.')
final QuillController? controller;
/// The text placeholder in the quill editor
@ -99,6 +100,7 @@ class QuillEditorConfigurations extends Equatable {
/// by any shortcut or keyboard operation. The text is still selectable.
///
/// Defaults to `false`. Must not be `null`.
// ignore: deprecated_member_use_from_same_package
bool get readOnly => controller?.readOnly != false;
/// Override [readOnly] for checkbox.
@ -383,6 +385,7 @@ class QuillEditorConfigurations extends Equatable {
@override
List<Object?> get props => [
placeholder,
// ignore: deprecated_member_use_from_same_package
controller?.readOnly,
];

@ -149,6 +149,7 @@ class QuillEditor extends StatefulWidget {
QuillController? controller,
QuillEditorConfigurations? configurations,
}) {
// 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).');

@ -23,6 +23,7 @@ class QuillEditorProvider extends InheritedWidget {
controller?.editorConfigurations ??
const QuillEditorConfigurations(),
controller = controller ??
// ignore: deprecated_member_use_from_same_package
editorConfigurations?.controller ??
QuillController.basic();

@ -95,6 +95,7 @@ class QuillRawEditorConfigurations extends Equatable {
});
/// Controls the document being edited.
@Deprecated('controller will be removed in future versions.')
final QuillController? controller;
/// Controls whether this editor has keyboard focus.

@ -23,7 +23,10 @@ class QuillRawEditor extends StatefulWidget {
required this.configurations,
controller,
super.key,
}) : assert((controller ?? configurations.controller) != null),
}) :
// ignore: deprecated_member_use_from_same_package
assert((controller ?? configurations.controller) != null),
// ignore: deprecated_member_use_from_same_package
controller = controller ?? configurations.controller,
assert(
configurations.maxHeight == null || configurations.maxHeight! > 0,

@ -1274,7 +1274,7 @@ class QuillRawEditorState extends EditorState
_cursorCont.show.value = widget.configurations.showCursor;
_cursorCont.style = widget.configurations.cursorStyle;
if (controller != oldWidget.configurations.controller) {
if (controller != oldWidget.controller) {
oldWidget.controller.removeListener(_didChangeTextEditingValue);
controller.addListener(_didChangeTextEditingValue);
updateRemoteValueIfNeeded();

@ -168,6 +168,7 @@ class QuillSimpleToolbarConfigurations extends QuillSharedToolbarProperties {
final Map<String, String>? fontFamilyValues;
@Deprecated('controller will be removed in future versions.')
final QuillController? controller;
/// By default it will be

@ -12,14 +12,11 @@ import 'simple_toolbar_provider.dart';
class QuillSimpleToolbar extends StatelessWidget
implements PreferredSizeWidget {
factory QuillSimpleToolbar({
/// Controller and configurations are required
///
/// Prefer: use controller and pass QuillEditorConfigurations in constructor for controller (using QuillControllerConfigurations).
/// Backward compatibility: use configurations and pass QuillController in constructor for configurations. (Will be removed in future versions.)
QuillSimpleToolbarConfigurations? configurations,
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).');

Loading…
Cancel
Save