Brett
2024-09-29 17:27:30 +08:00
parent 9f57971ee9
commit 6a446a7b33
39 changed files with 853 additions and 1079 deletions

View File

@@ -4,13 +4,21 @@ class Utils {
static List<T> toList<T>(String value, T f(Map<String, dynamic> map)) =>
(formatJson(value) as List).map((e) => f(e)).toList();
static T toObj<T>(String value, T f(Map<String, dynamic> map)) =>
f(formatJson(value));
static T toObj<T>(String value, T f(Map<String, dynamic> map)) => f(formatJson(value));
static List<dynamic> toListMap(String value) => formatJson(value);
static dynamic formatJson(String value) => jsonDecode(value);
static String checkOperationID(String? obj) =>
obj ?? DateTime.now().millisecondsSinceEpoch.toString();
static String checkOperationID(String? obj) => obj ?? DateTime.now().millisecondsSinceEpoch.toString();
static Map<String, dynamic> cleanMap(Map<String, dynamic> map) {
map.removeWhere((key, value) {
if (value is Map<String, dynamic>) {
cleanMap(value);
}
return value == null;
});
return map;
}
}