24 lines
422 B
Dart
24 lines
422 B
Dart
|
|
import 'dart:convert';
|
||
|
|
|
||
|
|
class StringUtils {
|
||
|
|
|
||
|
|
/// 字符串转换为 json
|
||
|
|
static String toJson(Object object) {
|
||
|
|
return jsonEncode(object);
|
||
|
|
}
|
||
|
|
|
||
|
|
static bool isEmpty(String? value) {
|
||
|
|
if (value == null || value == "") {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
static bool isNumber(String? value) {
|
||
|
|
if (isEmpty(value)) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return RegExp(r'^\d+$').hasMatch(value!);
|
||
|
|
}
|
||
|
|
}
|