import 'package:flutter/material.dart'; extension MapExt on Map { T? getCheck(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 on List? { 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}"; } extension ContextExt on BuildContext { ThemeData get theme => Theme.of(this); TextTheme get textTheme => theme.textTheme; TextStyle? get titleLarge => textTheme.titleLarge; TextStyle? get titleMedium => textTheme.titleMedium; TextStyle? get titleSmall => textTheme.titleSmall; TextStyle? get bodyLarge => textTheme.bodyLarge; TextStyle? get bodyMedium => textTheme.bodyMedium; TextStyle? get bodySmall => textTheme.bodySmall; ColorScheme get colorScheme => theme.colorScheme; Color get primaryColor => colorScheme.primary; Color get onPrimaryColor => colorScheme.onPrimary; Color get surfaceContainerHighColor => colorScheme.surfaceContainerHigh; Color get onSurfaceVariantColor => colorScheme.onSurfaceVariant; Color get onSurfaceColor => colorScheme.onSurface; }