Giter Club home page Giter Club logo

flutter-alice's Introduction

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) 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

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

Usage

Alice configuration

  1. Create Alice instance:
Alice alice = Alice();
  1. 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(navigatorKey: yourNavigatorKeyHere);

If you need to pass navigatorKey lazily, you can use:

alice.setNavigatorKey(yourNavigatorKeyHere);

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);

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(),
);

If you have other HTTP client you can use generic http call interface:

AliceHttpCall aliceHttpCall = AliceHttpCall(id);
alice.addHttpCall(aliceHttpCall);

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:flutter_alice/core/alice_http_client_extensions.dart';
import 'package:flutter_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());

flutter-alice's People

Contributors

jhomlala avatar sthasaugat avatar aakashbhusal7 avatar britannio avatar hautvfami avatar vietbq88 avatar itsjokr avatar mattisbrizard avatar darran-kelinske-fivestars avatar anggaraputrapratama avatar tvolkert avatar droidluv avatar tajchert avatar gadfly361 avatar jhomlalabsg avatar applysci avatar alyyasser avatar

Forkers

zordak

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.