Question : flutter check if string is number
Answered by : aashit-vyom
bool isNumeric(String s) { if (s == null) { return false; } return double.tryParse(s) != null;
}
Source : https://stackoverflow.com/questions/24085385/checking-if-string-is-numeric-in-dart | Last Update : Mon, 13 Jul 20
Question : check if string contain number dart flutter
Answered by : wrong-wallaby-5lijah95pjb1
void main() { var stringArr = ["Hello world", "Hello1 World", "H23llo", "H00Elo", "World"]; for (var i = 0; i < stringArr.length; i++) { bool found = stringArr[i].contains(new RegExp(r'[0-9]')); print(stringArr[i] + " -> " + found.toString()); }
}
Source : https://www.codevscolor.com/dart-string-contains-number | Last Update : Fri, 11 Mar 22
Question : check if string is number dart
Answered by : xanthous-xenomorph-qf4m2yjgrh3k
//From coflutter.com
bool isNumericUsingRegularExpression(String string) { final numericRegex = RegExp(r'^-?(([0-9]*)|(([0-9]*)\.([0-9]*)))$'); return numericRegex.hasMatch(string);
}
Source : https://coflutter.com/ | Last Update : Fri, 25 Nov 22
Question : flutter check if string contains only number
Answered by : yohannes-tesfay
final b = RegExp(r'^[0-9]+$').hasMatch(s);
Source : https://programming-idioms.org/idiom/137/check-if-string-contains-only-digits/3786/dart | Last Update : Thu, 22 Sep 22