Blame view

lib/common/request/request.dart 422 Bytes
056970d8   Key   feat: api
1
2
3
4
  import '../../utils/loading.dart';
  import 'exception.dart';
  import 'exception_handler.dart';
  
05f9b20a   Key   fixed: api调用方式,未完善
5
  Future<T?> request<T>(
056970d8   Key   feat: api
6
    Function() block, {
1892df31   Key   优化接口调用
7
    String loadingText = '请稍候...',
056970d8   Key   feat: api
8
9
10
    bool Function(ApiException)? onError,
  }) async {
    try {
05f9b20a   Key   fixed: api调用方式,未完善
11
      return await loading(block, loadingText: loadingText);
056970d8   Key   feat: api
12
    } catch (e) {
05f9b20a   Key   fixed: api调用方式,未完善
13
14
15
      if (!handleException(ApiException.from(e), onError: onError)) {
        rethrow;
      }
056970d8   Key   feat: api
16
    }
05f9b20a   Key   fixed: api调用方式,未完善
17
    return null;
056970d8   Key   feat: api
18
  }