Blame view

lib/utils/loading.dart 441 Bytes
056970d8   Key   feat: api
1
2
  import 'package:flutter_easyloading/flutter_easyloading.dart';
  
05f9b20a   Key   fixed: api调用方式,未完善
3
4
5
  Future<T?> loading<T>(Function block, {String loadingText = '加载中...'}) async {
    if (loadingText.isNotEmpty) {
      showLoading(loadingText);
056970d8   Key   feat: api
6
7
    }
    try {
05f9b20a   Key   fixed: api调用方式,未完善
8
      return await block();
056970d8   Key   feat: api
9
10
11
12
13
    } catch (e) {
      rethrow;
    } finally {
      dismissLoading();
    }
056970d8   Key   feat: api
14
15
  }
  
05f9b20a   Key   fixed: api调用方式,未完善
16
17
  void showLoading(String text) {
    EasyLoading.show(status: text);
056970d8   Key   feat: api
18
19
20
21
22
  }
  
  void dismissLoading() {
    EasyLoading.dismiss();
  }