Im using an external barcode device for input ( with scan + submit(enter) combination ). I have RawKeyboardListener as TextField parent but it is not working when scanning. It seeing enter key but no barcode and gives some errors;
Platform key support for android is producing unsupported modifier combinations. 'package:flutter/src/services/raw_keyboard.dart': Failed assertion: line 721 pos 11: 'null'
raw_keyboard.dart
final Map<ModifierKey, KeyboardSide> modifiersPressed =
event.data.modifiersPressed;
final Map<PhysicalKeyboardKey, LogicalKeyboardKey> modifierKeys =
<PhysicalKeyboardKey, LogicalKeyboardKey>{};
for (final ModifierKey key in modifiersPressed.keys) {
final Set<PhysicalKeyboardKey> mappedKeys =
_modifierKeyMap[_ModifierSidePair(key, modifiersPressed[key])];
assert(
//Line 721;
mappedKeys != null,
'Platform key support for ${Platform.operatingSystem} is '
'producing unsupported modifier combinations.');
for (final PhysicalKeyboardKey physicalModifier in mappedKeys) {
modifierKeys[physicalModifier] = _allModifiers[physicalModifier];
}
}
_allModifiersExceptFn.keys.forEach(_keysPressed.remove);
if (event.data is! RawKeyEventDataFuchsia &&
event.data is! RawKeyEventDataMacOs) {
// On Fuchsia and macOS, the Fn key is not considered a modifier key.
_keysPressed.remove(PhysicalKeyboardKey.fn);
}
_keysPressed.addAll(modifierKeys);
Btw barcode scanner working well at google search or other apps
Here is my code;
child: Container(
width: 300,
height: 35,
child: RawKeyboardListener(
focusNode: barkodFocus,
autofocus: true,
onKey: (key) {
print(key.toString());
},
child: TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.all(8),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(5)))),
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
readOnly: false,
controller: barkodController,
onSubmitted: (value) {
MusteriSiparisiRowModel satirModel =
MusteriSiparisiRowModel();
satirModel.setData(value, model).then((sonModel) {
setState(() {
barkod = value;
barkodFocus.requestFocus();
barkodController.selection = TextSelection(
baseOffset: 0,
extentOffset: barkodController.text.length);
if (sonModel != null) {
satirModel = sonModel;
bool add = true;
for (var i = 0;
i < satirlarModel.length;
i++) {
MusteriSiparisiRowModel m =
satirlarModel[i];
if (m.barkod == satirModel.barkod) {
m.setMiktar = m.getMiktar + 1;
add = false;
}
}
if (add == true) {
satirlarModel.add(satirModel);
}
} else {
scaffoldKey.currentState
.showSnackBar(SnackBar(
content: Row(
children: [
Icon(Icons.announcement),
Padding(padding: EdgeInsets.all(20)),
Text("Barkod Bulunamadı."),
],
)));
}
});
});
},
),
)),
Print(key) works for enter but not for barcode
[√] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.18363.1016], locale tr-TR)
• Flutter version 1.20.2 at C:\src\flutter\flutter_windows_v1.12.13+hotfix.5-stable\flutter
• Framework revision bbfbf1770c (3 weeks ago), 2020-08-13 08:33:09 -0700
• Engine revision 9d5b21729f
• Dart version 2.9.1
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\DELL\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code (version 1.48.2)
• VS Code at C:\Users\DELL\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.13.2
[√] Connected device (2 available)
• G0550 (mobile) • SAN8PSS5S5PMVEUKRCY • android-arm • Android 4.2.2 (API 17)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• No issues found!