remove spaces only if number

Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
This commit is contained in:
Sahil Yeole 2023-10-17 18:35:38 +05:30
parent c00d4c1a7b
commit 1ad740800b

View File

@ -265,20 +265,21 @@ class _ConnectionPageState extends State<ConnectionPage>
return [emptyPeer];
}
else {
if (textEditingValue.text.contains(" ")) {
textEditingValue = TextEditingValue(
text: textEditingValue.text.replaceAll(" ", ""),
selection: textEditingValue.selection,
);
}
String textWithoutSpaces = textEditingValue.text.replaceAll(" ", "");
if (int.tryParse(textWithoutSpaces) != null) {
textEditingValue = TextEditingValue(
text: textWithoutSpaces,
selection: textEditingValue.selection,
);
}
return peers.where((peer) =>
peer.id.toLowerCase().contains(textEditingValue.text.toLowerCase()) ||
peer.username.toLowerCase().contains(textEditingValue.text.toLowerCase()) ||
peer.hostname.toLowerCase().contains(textEditingValue.text.toLowerCase()) ||
peer.alias.toLowerCase().contains(textEditingValue.text.toLowerCase()) ||
peer.platform.toLowerCase().contains(textEditingValue.text.toLowerCase()))
.toList();
return peers.where((peer) =>
peer.id.toLowerCase().contains(textEditingValue.text.toLowerCase()) ||
peer.username.toLowerCase().contains(textEditingValue.text.toLowerCase()) ||
peer.hostname.toLowerCase().contains(textEditingValue.text.toLowerCase()) ||
peer.alias.toLowerCase().contains(textEditingValue.text.toLowerCase()) ||
peer.platform.toLowerCase().contains(textEditingValue.text.toLowerCase()))
.toList();
}
},