基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 4 години
преди 3 години
преди 4 години
преди 3 години
преди 4 години
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. typedef Future InitMethod();
  2. class Application {
  3. // 初始化方法
  4. static List<InitMethod> _initMethods = List();
  5. ///有标签的方法用于没有页面的第三模块调用
  6. static Map<String, InitMethod> _initStringMethods = Map();
  7. static Future init() async {
  8. for (InitMethod method in _initMethods) {
  9. await method();
  10. }
  11. return Future.delayed(Duration.zero);
  12. }
  13. static addMethod(InitMethod method) {
  14. _initMethods.add(method);
  15. }
  16. static addStringMethod({String type, InitMethod method}) {
  17. if(type==null||method==null){
  18. return;
  19. }
  20. _initStringMethods[type] = method;
  21. }
  22. static bool hasStringMethod(String type){
  23. return _initStringMethods.containsKey(type);
  24. }
  25. static doStringMethod(String type){
  26. if(_initStringMethods.containsKey(type)){
  27. print("存在方法"+type);
  28. _initStringMethods[type]();
  29. }else{
  30. print("不存在方法"+type);
  31. }
  32. }
  33. }