flutterflutter-textformfieldflutter-textinputfieldzebra-scanners

flutter Enter event not found on zebra tc77?


We need to scan using zebra tc77 but enter event not found at the end of text , even after we have enabled enter key at settings?

enter image description here


  _onChangeListener(String val) {
    if(val.isEmpty) return;
    SystemChannels.textInput.invokeMethod('TextInput.hide');
    Log.d("onChange $val");
    Log.d("Last char as int ${val.codeUnitAt(val.length -1)}");

    setState(() {
      logs.add("Scanned data : $val, length : ${val.length}");
      logs.add("Last char as int ${val.codeUnitAt(val.length -1)}");
      if(val.codeUnitAt(val.length -1) == 13){
        logs.add("Enter key found as logical key (13)");
      } else {
        logs.add("Enter key not found as logical key");
      }

      if(val.contains('\n') || val.contains('\r')){
        logs.add("Enter key found as character");
      } else {
        logs.add("Enter key not found as character");
      }
    });

    return;
}

Solution

  • i have used rawkeyboardlistener to get scan event

    RawKeyboardListener(
     onKey:(RawKeyEvent event) {
        String e = event.character ?? '';
        if (e.isNotEmpty && isValid(e) || e == '-') {
          Log.d("Shelf Data ${e}");
          scanData += e;
        }
        if (e == '\n' || e == '\r') {
          Log.d("Entered Shelf");
              scanShelfTextField.clear();
            });
          }
        })