8000 [Add2App] It's possible to lose the ability to input characters using the keyboard on Android · Issue #35054 · flutter/flutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Add2App] It's possible to lose the ability to input characters using the keyboard on Android #35054
Closed
@dannyvalentesonos

Description

@dannyvalentesonos

Using the new embedding API for Android to embed Flutter in an existing app, it is possible for the app to stop taking input from the keyboard.

The following simple Flutter module code will create a TextField.

  1. Launch the Flutter module in the existing app
  2. Start typing text in the field
  3. With focus still in the field, background the app using the Home button
  4. Come back to the app. Notice the focus is still in the field, but the keyboard is hidden (expected)
  5. Select the field again and start typing. Notice text is not entered in the field.

The following is the code in the flutter module:

// Main app entry
void main() {
   runApp(MyApp());
}

class DefaultEmptyPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
            child: TextField(
              decoration: InputDecoration(
                  labelText: "Enter Text"
              ),
            )
        )
    );
  }
}

class MyApp extends StatelessWidget {
  MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'My App',
      home: DefaultEmptyPage(),
    );
  }
}

The following exception occurs after coming back to the app and tapping in the text field:

2019-06-25 09:17:51.732 7330-7330/com.example.app E/MethodChannel#flutter/textinput: Failed to handle method call
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
        at io.flutter.plugin.editing.TextInputPlugin.setTextInputEditingState(TextInputPlugin.java:208)
        at io.flutter.plugin.editing.TextInputPlugin.access$400(TextInputPlugin.java:26)
        at io.flutter.plugin.editing.TextInputPlugin$1.setEditingState(TextInputPlugin.java:66)
        at io.flutter.embedding.engine.systemchannels.TextInputChannel$1.onMethodCall(TextInputChannel.java:76)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
        at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:90)
        at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:234)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:323)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
2019-06-25 09:17:51.775 7330-7471/com.example.app E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference, null)
    #0      JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:149:7)
    #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
    <asynchronous suspension>
    #2      OptionalMethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:424:36)
    <asynchronous suspension>
    #3      TextInputConnection.setEditingState (package:flutter/src/services/text_input.dart:649:30)
    #4      EditableTextState._updateRemoteEditingValueIfNeeded (package:flutter/src/widgets/editable_text.dart:1093:26)
    #5      EditableTextState._didChangeTextEditingValue (package:flutter/src/widgets/editable_text.dart:1400:5)
    #6      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:206:21)
    #7      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:273:5)
    #8      TextEditingController.selection= (package:flutter/src/widgets/editable_text.dart:166:5)
    #9      EditableTextState._handleSelectionChanged (package:flutter/src/widgets/editable_text.dart:1211:23)
    #10     RenderEditable._handlePotentialSelectionChange (package:flutter/src/rendering/editable.dart:369:5)
    #11     RenderEditable.selectPositionAt (package:flutter/src/rendering/editable.dart:1416:9)
    #12     RenderEditable.selectPosition (package:flutter/src/rendering/editable.dart:1388:5)
    #13     _TextFieldState._handleSingleTapUp (package:flutter/src/material/text_field.dart:760:27)
    #14     _TextSelectionGestureDetectorState._handleTapUp (package:flutter/src/widgets/text_selection.dart:929:16)
    #15     TapGestureRecognizer._checkUp.<anonymous closure> (package:flutter/src/gestures/tap.dart:383:49)
    #16     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:198:24)
    #17     TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:383:11)
    #18     TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:332:7)
    #19     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
    #20     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
    #21     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
    #22     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
    #23     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
    #24     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
    #25     _rootRunUnary (dart:async/zone.dart:1136:13)
    #26     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
    #27     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
    #28     _invoke1 (dart:ui/hooks.dart:239:10)
    #29     _dispatchPointerDataPacket (dart:ui/hooks.dart:159:5)
2019-06-25 09:17:51.935 7330-7330/com.example.app D/FlutterView: sendViewportMetricsToFlutter()

Metadata

Metadata

Assignees

Labels

a: existing-appsIntegration with existing apps via the add-to-app flowa: text inputEntering text in a text field or keyboard related problemswaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0