// If it starts with /, it's a command
onChanged: (value) async {
// Check for mode changes first, but only
// if the type is main
if (widget.type == TextFieldType.main) {
if (value == "/search" || value == "/s") {
setState(() {
uiMode = "search";
});
// Clear the text field
// _primaryController.clear();
} else if (value == "/users" || value == "/u") {
setState(() {
uiMode = "users";
});
// Clear the text field
// _primaryController.clear();
} else if (value == "/t" || value == ";") {
setState(() {
uiMode = "think";
});
// _primaryController.clear();
}
// Next, handle the commands
if (uiMode == "search") {
// Search
var res = await searchThoughts(context, value);
setState(() {
searchResults = res;
});
}
}
},
Add the command processing stuff back in. Can't use the following code because enabling the
onChange
function breaks backspacing on android/linux. See https://stackoverflow.com/questions/71783012/backspace-text-field-flutter-on-android-devices-not-workinghttps://github.com/mind-co/comind-flutter/blob/335976f7c501ad53ff95e09301d0143011c9ef84/lib/input_field.dart#L221
The old code was this: