123456789101112131415161718192021222324252627282930 |
- extension MapExt<K, V> on Map<K, V> {
- T? getCheck<T>(K? key) {
- if (key == null || !containsKey(key)) {
- return null;
- }
- var value = this[key];
- if (value is! T) {
- return null;
- }
- return value as T?;
- }
- }
- extension StringExt on String? {
- bool get isNullOrEmpty {
- return this == null || this!.isEmpty;
- }
- }
- extension ListExt<T> on List<T>? {
- bool get isNullOrEmpty {
- return this == null || this!.isEmpty;
- }
- }
- extension DateTimeExt on DateTime {
- String get yyyyMMddHHmmss =>
- "$year-${month < 10 ? "$month".padLeft(2, "0") : month}-$day ${hour < 10 ? "$hour".padLeft(2, "0") : hour}:${minute < 10 ? "$minute".padLeft(2, "0") : minute}:${second < 10 ? "$second".padLeft(2, "0") : second}";
- }
|