This package is a simple http inspector for dart http clients. It intercepts and stores all HTTP responses (including their requests) inside your application, and provides a UI for inspecting their content.
- Depend on it Add this to your package's pubspec.yaml file:
dependencies:
http_ui_logger: ^0.0.3
- Install it You can install packages from the command line:
$ flutter pub get
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
- Import it Now in your Dart code, you can use:
import 'package:http_ui_logger/LoggerClient.dart';
import 'package:http_ui_logger/ResponseListWidget.dart';
You have two options:
- Create a logger client:
import 'package:http_ui_logger/LoggerClient.dart';
...
final client = LoggerClient.client()
//sample request
client.get('https://www.googleapis.com/books/v1/volumes?q={http}');
- Wrap your own client:
import 'package:http_ui_logger/LoggerClient.dart';
...
final client = LoggerClient.wrap(yourClient)
//sample request
client.get('https://www.googleapis.com/books/v1/volumes?q={http}');
the client is a simple client from http library wrapped by interceptor.
When you want to see requests made, simply push a ResponseListWidget
widget with used client to the screen:
import 'package:http_ui_logger/LoggerClient.dart';
import 'package:http_ui_logger/ResponseListWidget.dart';
...
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ResponseListWidget(client)
);