Skip to content

doc: update controller length extension method deprecation message #2483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

realth000
Copy link
Contributor

Description

V11 deprecates the length extension method on controller and the deprecation message suggests to use selection.baseOffset instead.

However it will cause assertion failure for the following code

  void insertEmbeddable(Embeddable embed) {
    final position = selection.baseOffset;
    this
      ..replaceText(
        position, // In former versions, here is `index`.
        position, // In former versions, here is `length`.
        embed,
        null,
      )
      ..moveCursorToPosition(position + 1);
  }

Assertion failure:

flutter: ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ [error] | 3:28:44 815ms | 
flutter: │ 'package:flutter_quill/src/document/nodes/container.dart': Failed assertion: line 138 pos 12: 'index == 0 || (index > 0 && index < length)': is not true.
flutter: │ StackTrace: #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:63:4)
flutter: │ #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:45:5)
flutter: │ #2      QuillContainer.insert (package:flutter_quill/src/document/nodes/container.dart:138:12)
flutter: │ #3      Document.compose (package:flutter_quill/src/document/document.dart:451:15)
flutter: │ #4      Document.insert (package:flutter_quill/src/document/document.dart:88:5)
flutter: │ #5      Document.replace (package:flutter_quill/src/document/document.dart:144:17)
flutter: │ #6      QuillController.replaceText (package:flutter_quill/src/controller/quill_controller.dart:284:24)
flutter: │ #7      BBCodeExt.insertEmbeddable (package:flutter_bbcode_editor/src/editor_controller.dart:120:9)
flutter: │ #8      BBCodeEditorToolbarImageButton.build.<anonymous closure> (package:flutter_bbcode_editor/src/tags/image/image_button.dart:205:20)
flutter: │ <asynchronous suspension>
flutter: │ }

I think it should be a typo as the getter actually now is selection.extentOffset - selection.baseOffset.

This PR updates the deprecation message on length method to match its implementation.

Related Issues

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

Copy link
Collaborator

@EchoEllet EchoEllet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@EchoEllet EchoEllet merged commit ef58496 into singerdmx:master Feb 20, 2025
7 checks passed
@realth000 realth000 deleted the fix-controller-ext-length-deprecation branch February 20, 2025 12:27
CatHood0 pushed a commit to CatHood0/flutter-quill that referenced this pull request Mar 12, 2025
…ingerdmx#2483)

* docs: update controller length extension method deprecation message

* docs: update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants