flutter_alice

Last updated:

0 purchases

flutter_alice Image
flutter_alice Images
Add to Cart

Description:

flutter alice

Alice #



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) and Chucker (https://github.com/ChuckerTeam/chucker).
Overlay bubble version of Alice: https://github.com/jhomlala/alice










































Supported Dart http client plugins:

Dio
HttpClient from dart:io package
Http from http/http package
Chopper
Generic HTTP client

Features:
✔️ Detailed logs for each HTTP calls (HTTP Request, HTTP Response)
✔️ Inspector UI for viewing HTTP calls
✔️ Statistics
✔️ Support for top used HTTP clients in Dart
✔️ Error handling
✔️ HTTP calls search
✔️ Bubble overlay entry
Install #

Add this to your pubspec.yaml file:

dependencies:
flutter_alice: ^1.0.1
copied to clipboard

Install it

$ flutter pub get
copied to clipboard

Import it

import 'package:flutter_alice/alice.dart';
copied to clipboard
Usage #
Alice configuration #

Create Alice instance:

Alice alice = Alice();
copied to clipboard

Add navigator key to your application:

MaterialApp( navigatorKey: alice.getNavigatorKey(), home: ...)
copied to clipboard
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(navigatorKey: yourNavigatorKeyHere);
copied to clipboard
If you need to pass navigatorKey lazily, you can use:
alice.setNavigatorKey(yourNavigatorKeyHere);
copied to clipboard
This is minimal configuration required to run Alice. Can set optional settings in Alice constructor, which are presented below. If you don't want to change anything, you can move to Http clients configuration.
Additional settings #
If you want to use dark mode just add darkTheme flag:
Alice alice = Alice(..., darkTheme: true);
copied to clipboard
HTTP Client configuration #
If you're using Dio, you just need to add interceptor.
Dio dio = Dio();
dio.interceptors.add(alice.getDioInterceptor());
copied to clipboard
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);
});
copied to clipboard
If you're using http from http/http package:
http.get('https://jsonplaceholder.typicode.com/posts').then((response) {
alice.onHttpResponse(response);
});
copied to clipboard
If you're using Chopper. you need to add interceptor:
chopper = ChopperClient(
interceptors: alice.getChopperInterceptor(),
);
copied to clipboard
If you have other HTTP client you can use generic http call interface:
AliceHttpCall aliceHttpCall = AliceHttpCall(id);
alice.addHttpCall(aliceHttpCall);
copied to clipboard
Extensions #
You can use extensions to shorten your http and http client code. This is optional, but may improve your codebase.
Example:

Import:

import 'package:flutter_alice/core/alice_http_client_extensions.dart';
import 'package:flutter_alice/core/alice_http_extensions.dart';
copied to clipboard

Use extensions:

http
.post('https://jsonplaceholder.typicode.com/posts', body: body)
.interceptWithAlice(alice, body: body);
copied to clipboard
httpClient
.postUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts"))
.interceptWithAlice(alice, body: body, headers: Map());
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.