Repository: flutter
Issue: No text input from HID device after hiding keyboard/inputAccessory programmatically
Labels: a: text input,platform-ios,framework,f: material design,has reproducible steps,P2,found in release: 3.3,workaround available,found in release: 3.7,team-ios,triaged-ios,fyi-text-input

I am currently developing a Flutter app which uses a bluetooth barcode scanner to input text in a text field. The bluetooth scanner is detected as a HID.

One of the constraints of this application is, that a user cannot enter a barcode manually using the virtual keyboard. To prevent this, I automatically hide the keyboard via `SystemChannels.textInput.invokeMethod('TextInput.hide')` on focus gain.

On Android, this works without issues (Android 9, Samsung tablet).

On iOS, when a HID is connected, it shows what seems to be called `inputAccessory` when a text field is focused. I noticed that after hiding the keyboard/inputAccessory programmatically, there is no input detected from the barcode scanner anymore, even if the text field is still in focus.

Invoking `TextInput.show` restores functionality, but also (obviously) shows the inputAccessory again, which is undesirable.

I would accept this as an iOS specific quirk, however, when I hide the inputAccessory manually by tapping on its down arrow, it becomes hidden, but input from the scanner is still detected and put into the text field. In addition to this, I also noticed that after hiding the inputAccessory manually, I am unable to make it reappear by invoking `TextInput.show` again.

As I can reach the desired keyboard/inputAccessory state when hiding the inputAccessory manually, I assume there must be a way to achieve the same state programmatically. Is there a way to do this in Flutter?

Alternatively, is there a way to specifically only hide the virtual keyboard, but not the inputAccessory? I don't mind the inputAccessory bar, as long as I can prevent users from using the virtual keyboard to input barcodes.

If anyone knows of a solution or workaround, please let me know.

I'm attaching a two videos to illustrate the issue.

## Steps to Reproduce

1. focus a `TextField`
2. call `SystemChannels.textInput.invokeMethod('TextInput.hide')`
3. scan a barcode / type something on a physical keyboard

Expected result: text should be put into text field
Actual result: no text input happening

## Videos

First is the flow as described in "Steps to Reproduce", i.e. focus a textfield, hide the keyboard/inputAccessory, scan an item: https://gfycat.com/rashoccasionalboilweevil

Second is about the quirk I mentioned, that initially I can hide and show the inputAccessory without issues, but if I hide the inputAccessory manually (by clicking on the arrow), I cannot reveal the inputAccessory programmatically anymore, but in this case the input of the scanner is respected and handled: https://gfycat.com/selfishmelodicindri

## Code
Here is the relevant code of an example app, the same you see in the videos:
```dart
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController _textFieldController = TextEditingController();
  FocusNode _textFieldFocus = FocusNode();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text(
              '1. click "request focus"\n'
              '(keyboard indicator should be visible)\n'
              '2. click "hide keyboard"\n'
              '3. scan a barcode / type something on the physical keyboard\n'
              'expected: text should be put into text field\n'
              'actual: no text input happening\n'
          ),
          TextField(
            onSubmitted: (text) => debugPrint('text submitted: $text'),
            controller: _textFieldController,
            focusNode: _textFieldFocus,
            autofocus: false,
          ),
          ButtonBar(
            children: <Widget>[
              RaisedButton(
                child: Text('request focus'),
                onPressed: () => _textFieldFocus.requestFocus(),
              ),
              RaisedButton(
                child: Text('hide keyboard'),
                onPressed: () =>
                    SystemChannels.textInput.invokeMethod('TextInput.hide'),
              ),
              RaisedButton(
                child: Text('show keyboard'),
                onPressed: () =>
                    SystemChannels.textInput.invokeMethod('TextInput.show'),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

```

## Logs
I have tested multiple Flutter versions, but here is the log after trying it with the master branch state
```
[✓] Flutter (Channel master, v1.9.8-pre.79, on Mac OS X 10.14.3 18D42, locale en-DE)
    • Flutter version 1.9.8-pre.79 at /Users/ren/Stuff/flutter
    • Framework revision 72cacb4040 (2 days ago), 2019-09-03 18:00:45 -0700
    • Engine revision e7f9ef6aa0
    • Dart version 2.5.0 (build 2.5.0-dev.4.0 36985859e4)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/ren/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Users/ren/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.5)
    • Android Studio at /Users/ren/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.37.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • Andreas' iPhone 6S • 8bef8d20ae638b8f483f05cfc456b4ab4edb8177 • ios • iOS 12.4

• No issues found!
```