Skip to content
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

Typing in editor adds the previous typed text after recreating controller #31

Closed
Amir-P opened this issue Sep 1, 2022 · 0 comments · Fixed by #35
Closed

Typing in editor adds the previous typed text after recreating controller #31

Amir-P opened this issue Sep 1, 2022 · 0 comments · Fixed by #35

Comments

@Amir-P
Copy link
Member

Amir-P commented Sep 1, 2022

I've only experienced this issue on Android. Only way to prevent it for now is to recreate editor widget state every time controller changes.

Steps to Reproduce

  1. Type something in editor
  2. Recreate controller
  3. Type something in editor

I haven't done any investigations yet but I think this issue roots in our RawEditorStateTextInputClientMixin and its _lastKnownRemoteTextEditingValue. I believe this issue will be solved after upgrading package to support Flutter 3.3 (By using granular text updates)

Recreating a new controller and passing it to editor I'm getting this log:

E/MethodChannel#flutter/textinput(10622): Failed to handle method call
E/MethodChannel#flutter/textinput(10622): java.lang.IndexOutOfBoundsException: invalid composing start: 0
E/MethodChannel#flutter/textinput(10622): 	at io.flutter.embedding.engine.systemchannels.TextInputChannel$TextEditState.<init>(TextInputChannel.java:777)
E/MethodChannel#flutter/textinput(10622): 	at io.flutter.embedding.engine.systemchannels.TextInputChannel$TextEditState.fromJson(TextInputChannel.java:738)
E/MethodChannel#flutter/textinput(10622): 	at io.flutter.embedding.engine.systemchannels.TextInputChannel$1.onMethodCall(TextInputChannel.java:101)
E/MethodChannel#flutter/textinput(10622): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#flutter/textinput(10622): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#flutter/textinput(10622): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#flutter/textinput(10622): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#flutter/textinput(10622): 	at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#flutter/textinput(10622): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#flutter/textinput(10622): 	at android.os.Looper.loop(Looper.java:246)
E/MethodChannel#flutter/textinput(10622): 	at android.app.ActivityThread.main(ActivityThread.java:8633)
E/MethodChannel#flutter/textinput(10622): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/textinput(10622): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/MethodChannel#flutter/textinput(10622): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
E/flutter (10622): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(error, invalid composing start: 0, null, java.lang.IndexOutOfBoundsException: invalid composing start: 0
E/flutter (10622): 	at io.flutter.embedding.engine.systemchannels.TextInputChannel$TextEditState.<init>(TextInputChannel.java:777)
E/flutter (10622): 	at io.flutter.embedding.engine.systemchannels.TextInputChannel$TextEditState.fromJson(TextInputChannel.java:738)
E/flutter (10622): 	at io.flutter.embedding.engine.systemchannels.TextInputChannel$1.onMethodCall(TextInputChannel.java:101)
E/flutter (10622): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/flutter (10622): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter (10622): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/flutter (10622): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter (10622): 	at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (10622): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (10622): 	at android.os.Looper.loop(Looper.java:246)
E/flutter (10622): 	at android.app.ActivityThread.main(ActivityThread.java:8633)
E/flutter (10622): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter (10622): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/flutter (10622): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
E/flutter (10622): )
E/flutter (10622): #0      JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:164:7)
E/flutter (10622): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (10622): <asynchronous suspension>

flutter doctor -v:

[✓] Flutter (Channel stable, 3.0.4, on macOS 12.4 21F79 darwin-arm, locale
    en-US)
    • Flutter version 3.0.4 at /Users/amirpanahandeh/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 85684f9300 (9 weeks ago), 2022-06-30 13:22:47 -0700
    • Engine revision 6ba2af10bb
    • Dart version 2.17.5
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/amirpanahandeh/SDK
    • Platform android-32, build-tools 30.0.3
    • ANDROID_HOME = /Users/amirpanahandeh/SDK
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.1.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 58.0.3
    • Dart plugin version 211.7727

[✓] VS Code (version 1.70.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0

[✓] Connected device (3 available)
    • SM A015F (mobile) • R9HN60D11QJ • android-arm    • Android 11 (API 30)
    • macOS (desktop)   • macos       • darwin-arm64   • macOS 12.4 21F79
      darwin-arm
    • Chrome (web)      • chrome      • web-javascript • Google Chrome
      104.0.5112.101

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Minimum code to reproduce:

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final focusNode = FocusNode();
  var controller = FleatherController();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: FleatherField(controller: controller, focusNode: focusNode),
        floatingActionButton: FloatingActionButton(
          onPressed: () => setState(() => controller = FleatherController()),
          child: const Icon(Icons.close),
        ),
      ),
    );
  }
}
telegram-cloud-document-4-5802932096037031070.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant