new version sdk
This commit is contained in:
@@ -1,27 +1,16 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Utils {
|
||||
static List<T> toList<T>(String? value, T f(Map<String, dynamic> map)) {
|
||||
var list = _formatJson(value);
|
||||
if (null == list) return <T>[];
|
||||
return (list as List).map((e) => f(e)).toList();
|
||||
}
|
||||
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 List<dynamic> toListMap(String? value) => _formatJson(value) ?? [];
|
||||
static List<dynamic> toListMap(String value) => _formatJson(value);
|
||||
|
||||
static dynamic _formatJson(String? value) {
|
||||
if (null == value) return null;
|
||||
return jsonDecode(_printValue(value));
|
||||
}
|
||||
static dynamic _formatJson(String value) => jsonDecode(value);
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
static String checkOperationID(String? obj) =>
|
||||
obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user