alice 0.0.23 copy "alice: ^0.0.23" to clipboard
alice: ^0.0.23 copied to clipboard

outdated

Alice is an HTTP Inspector tool which helps debugging http requests. It catches and stores http requests and responses, which can be viewed via simple UI.

Alice #

pub package pub package pub package

Alice is an HTTP Inspector tool for Flutter which helps debugging http requests. It catches and stores http requests and responses, which can be viewed via simple UI. It is inspired from Chuck ( https://github.com/jgilfelt/chuck ).

Suported Dart http client plugins:

  • Dio
  • HttpClient from dart:io package
  • Http from http/http package
  • Chopper

Features:
✔️ Detailed logs for each HTTP calls (HTTP Request, HTTP Response)
✔️ Inspector UI for viewing HTTP calls
✔️ Save HTTP calls to file
✔️ Statistics
✔️ Notification on HTTP call
✔️ Support for top used HTTP clients in Dart
✔️ Error handling
✔️ Shake to open inspector

Install #

  1. Add this to your pubspec.yaml file:
dependencies:
  alice: ^0.0.23
  1. Install it
$ flutter packages get
  1. Import it
import 'package:alice/alice.dart';

Usage #

Alice configuration #

Create Alice instance:

Alice alice = Alice(showNotification: true);

Alice default behaviour is to show notification with http requests. You can disable it in Alice constructor.

Add navigator key to your application:

MaterialApp( navigatorKey: alice.getNavigatorKey(), home: ...)

You need to add this navigator key in order to show inspector UI. You can use also your navigator key in Alice:

Alice alice = Alice(showNotification: true, navigatorKey: yourNavigatorKeyHere);

You can set showInspectorOnShake in Alice constructor to open inspector by shaking your device (default disabled):

Alice alice = Alice(showNotification: true, showInspectorOnShake: true, navigatorKey: yourNavigatorKeyHere);

If you want to use dark mode just add darkTheme flag:

Alice alice = Alice(..., darkTheme: true);

HTTP Client configuration #

If you're using Dio, you just need to add interceptor.

Dio dio = Dio();
dio.interceptors.add(alice.getDioInterceptor());

If you're using HttpClient from dart:io package:

httpClient
	.getUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts"))
	.then((request) async {
		alice.onHttpClientRequest(request);
		var httpResponse = await request.close();
		var responseBody = await httpResponse.transform(utf8.decoder).join();
		alice.onHttpClientResponse(httpResponse, request, body: responseBody);
 });

If you're using http from http/http package:

http.get('https://jsonplaceholder.typicode.com/posts').then((response) {
    alice.onHttpResponse(response);
});

If you're using Chopper. you need to add interceptor:

chopper = ChopperClient(
    interceptors: alice.getChopperInterceptor(),
);

To show inspector manually:

alice.showInspector();

Saving calls #

Alice supports saving logs to your mobile device storage. In order to make save feature works, you need to add in your Android application manifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Extensions #

You can use extensions to shorten your http and http client code. This is optional, but may improve your codebase. Example:

  1. Import:
import 'package:alice/core/alice_http_client_extensions.dart';
import 'package:alice/core/alice_http_extensions.dart';
  1. Use extensions:
http
    .post('https://jsonplaceholder.typicode.com/posts', body: body)
    .interceptWithAlice(alice, body: body);
httpClient
    .postUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts"))
    .interceptWithAlice(alice, body: body, headers: Map());

Example #

See complete example here: https://github.com/jhomlala/alice/blob/master/example/lib/main.dart

270
likes
0
pub points
97%
popularity

Publisher

unverified uploader

Alice is an HTTP Inspector tool which helps debugging http requests. It catches and stores http requests and responses, which can be viewed via simple UI.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

chewie, chopper, dio, flutter, flutter_local_notifications, http, open_file, package_info, path_provider, permission_handler, rxdart, shake, share, video_player

More

Packages that depend on alice