dio_shaker_interceptor 0.0.1 copy "dio_shaker_interceptor: ^0.0.1" to clipboard
dio_shaker_interceptor: ^0.0.1 copied to clipboard

The dio_shaker_interceptor package provides a Dio interceptor that allows you to easily inspect and debug network requests by shaking your device. It captures and displays detailed information about H [...]

example/lib/main.dart

import 'package:dio/dio.dart';
import 'package:dio_shaker_interceptor/dio_shaker_interceptor.dart';
import 'package:flutter/material.dart';

void main() {
  final dio = Dio();
  dio.interceptors.add(DioShakerInterceptor());

  runApp(MyApp(dio: dio));
}

class MyApp extends StatelessWidget {
  final Dio dio;

  const MyApp({super.key, required this.dio});

  @override
  Widget build(BuildContext context) {
    ShakerDioDetect.detectShakeAndOpenListCurlScreen(
      buildContext: context,
      navigatorKey: null,
    );
    return MaterialApp(
      title: 'Dio Shaker Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: HomePage(dio: dio),
    );
  }
}

class HomePage extends StatelessWidget {
  final Dio dio;

  const HomePage({super.key, required this.dio});

  Future<void> makeApiCall() async {
    try {
      await dio.get('https://jsonplaceholder.typicode.com/posts/1');
      await dio.post('https://jsonplaceholder.typicode.com/posts', data: {
        'title': 'foo',
        'body': 'bar',
        'userId': 1,
      });
    } catch (e) {
      debugPrint('API call error: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Dio Shaker Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: makeApiCall,
              child: const Text('Make API Request'),
            ),
          ],
        ),
      ),
    );
  }
}
3
likes
0
points
94
downloads

Publisher

verified publisherbreight-code.it

Weekly Downloads

The dio_shaker_interceptor package provides a Dio interceptor that allows you to easily inspect and debug network requests by shaking your device. It captures and displays detailed information about HTTP requests and responses, facilitating efficient development and troubleshooting.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, dio, equatable, flutter, flutter_bloc, flutter_localizations, get_it, path_provider, sensors_plus, share_plus

More

Packages that depend on dio_shaker_interceptor