Blame view

lib/utils/loading.dart 568 Bytes
4b2c2f07   Key   feat: 三种修改密码的类型及接口
1
  import 'package:flutter/foundation.dart';
056970d8   Key   feat: api
2
3
  import 'package:flutter_easyloading/flutter_easyloading.dart';
  
1892df31   Key   优化接口调用
4
  Future<T?> loading<T>(Function block, {String loadingText = '请稍后...'}) async {
05f9b20a   Key   fixed: api调用方式,未完善
5
6
    if (loadingText.isNotEmpty) {
      showLoading(loadingText);
056970d8   Key   feat: api
7
8
    }
    try {
05f9b20a   Key   fixed: api调用方式,未完善
9
      return await block();
056970d8   Key   feat: api
10
    } catch (e) {
4b2c2f07   Key   feat: 三种修改密码的类型及接口
11
12
13
      if (kDebugMode) {
        print("type=${e.runtimeType}, e=${e.toString()}");
      }
056970d8   Key   feat: api
14
15
16
17
      rethrow;
    } finally {
      dismissLoading();
    }
056970d8   Key   feat: api
18
19
  }
  
05f9b20a   Key   fixed: api调用方式,未完善
20
21
  void showLoading(String text) {
    EasyLoading.show(status: text);
056970d8   Key   feat: api
22
23
24
25
26
  }
  
  void dismissLoading() {
    EasyLoading.dismiss();
  }