http_provider.dart 618 B

12345678910111213141516171819
  1. import 'package:domain/constants/api_constants.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:riverpod_annotation/riverpod_annotation.dart';
  4. import 'package:plugin_platform/http/dio_engine.dart';
  5. import '../../dio_interceptors/interceptor_auth_dio.dart';
  6. import '../../dio_interceptors/interceptor_status_code_dio.dart';
  7. part 'http_provider.g.dart';
  8. @Riverpod(keepAlive: true)
  9. DioEngine dioEngine(Ref ref) {
  10. return DioEngine(
  11. ApiConstants.baseUrl,
  12. interceptors: [StatusCodeDioInterceptors(), AuthDioInterceptors()], //需要加上与App关联的一些拦截处理
  13. );
  14. }