1234567891011121314151617181920212223242526272829303132333435 |
- import 'package:get/get.dart';
- ///状态模块构建函数声明
- typedef StateModuleBuilder<T extends StateModuleBase> = T Function();
- ///持久化状态
- abstract class PersistentalbeState {
- /// 转换为持久存储Json
- Map<String, dynamic> toPersistenceJson();
- /// 接收持久存储Json
- Future<void> acceptPersistenceJson(Map<String, dynamic> map);
- }
- ///对持久化的map支撑字典进行相关扩展
- extension PersistentPropPickerEx on Map<String, dynamic> {
- void pickPersistentProp(String key, void Function(dynamic value) fn) {
- if (!containsKey(key)) return;
- final value = this[key];
- if (value == null) return;
- fn(value);
- }
- void pickPersistentProps(Map<String, void Function(dynamic value)> fnMaps) {
- for (var key in fnMaps.keys) {
- pickPersistentProp(key, (value) {
- fnMaps[key]?.call(value);
- });
- }
- }
- }
- abstract class StateModuleBase extends GetxService
- implements PersistentalbeState {}
|