Skip to main content

durbun_dio 0.3.0 copy "durbun_dio: ^0.3.0" to clipboard
durbun_dio: ^0.3.0 copied to clipboard

Dio adapter wrapper and interceptor for Dürbün: reports requests made through adapters that bypass dart:io (NativeAdapter, cronet_http) and applies the desktop's mocks.

example/main.dart

// Dio with an adapter that bypasses dart:io (here a stand-in for
// native_dio_adapter's NativeAdapter / cronet_http) reported to Dürbün.
//
// In a real app: `dio.httpClientAdapter = DurbunDioAdapter(NativeAdapter());`
// and start the SDK with `Durbun.run` / `Durbun.init` as described in
// package:durbun.
import 'package:dio/dio.dart';
import 'package:durbun/durbun.dart';
import 'package:durbun_dio/durbun_dio.dart';
import 'package:flutter/widgets.dart';

Future<void> main() async {
  await Durbun.run(() async {
    WidgetsFlutterBinding.ensureInitialized();
    final dio = Dio(BaseOptions(baseUrl: 'https://api.example.com'))
      // Wrap the adapter that does the work, e.g. DurbunDioAdapter(NativeAdapter()).
      ..httpClientAdapter = DurbunDioAdapter(HttpClientAdapter());
    dio.interceptors.add(LogInterceptor());
    try {
      await dio.get<Object?>('/users');
    } on DioException catch (e) {
      Durbun.w('request failed', error: e);
    }
  });
}
0
likes
160
points
185
downloads

Documentation

API reference

Publisher

verified publisherappnify.dev

Weekly Downloads

Dio adapter wrapper and interceptor for Dürbün: reports requests made through adapters that bypass dart:io (NativeAdapter, cronet_http) and applies the desktop's mocks.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#dio #network #debugging #inspector #logging

License

MIT (license)

Dependencies

dio, durbun, flutter

More

Packages that depend on durbun_dio