fl_dio 1.5.1 copy "fl_dio: ^1.5.1" to clipboard
fl_dio: ^1.5.1 copied to clipboard

Extended dio and added three interceptors and the JsonParse component.

fl_dio #

Extended dio and added three interceptors and the JsonParse component. #

Example web #

使用方法和 Dio 一致,只需替换 DioExtendedDio 就可以不用写 try catch ,统一返回 ExtendedResponse #

void main() {
  GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

  /// 必须设置 DebuggerInterceptorHelper
  /// You must set up DebuggerInterceptorHelper
  DebuggerInterceptorHelper().navigatorKey = navigatorKey;

  /// 设置JsonParse字体颜色
  /// Set the JsonParse font color
  JsonParse.color = JsonParseColor();

  /// toast 提示
  /// toast Tips
  JsonParse.toastBuilder = (String content) {
    showToast('已复制:$content');
  };

  ///  你也可以使用自己的dio,并添加拦截器,拦截器是独立存在的
  ///  You can also use your own dio and add interceptors, which stand alone
  List<Interceptor>list = [

    /// 日志打印
    LoggerInterceptor(),

    /// debug 调试工具
    DebuggerInterceptor(),

    /// cookie 保存和获取
    CookiesInterceptor(),
  ];
  final dio = ExtendedDio()
    ..interceptors.addAll(interceptors);


  runApp(MaterialApp(
    navigatorKey: navigatorKey,
    home: const Scaffold(body: HomePage()),
  ));
}

3
likes
160
points
324
downloads

Publisher

unverified uploader

Weekly Downloads

Extended dio and added three interceptors and the JsonParse component.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

dio, dio_web_adapter, flutter, http_parser

More

Packages that depend on fl_dio