flutter-alice
所属分类:WEB开发
开发工具:Dart
文件大小:0KB
下载次数:0
上传日期:2023-08-01 08:11:11
上 传 者:
sh-1993
说明: Flutter应用的Http请求检查器,
(Http request inspector for Flutter application,)
文件列表:
.metadata (308, 2023-10-03)
CHANGELOG.md (3352, 2023-10-03)
LICENSE (11357, 2023-10-03)
alice.iml (964, 2023-10-03)
example/ (0, 2023-10-03)
example/.metadata (305, 2023-10-03)
example/android/ (0, 2023-10-03)
example/android/app/ (0, 2023-10-03)
example/android/app/build.gradle (2054, 2023-10-03)
example/android/app/src/ (0, 2023-10-03)
example/android/app/src/debug/ (0, 2023-10-03)
example/android/app/src/debug/AndroidManifest.xml (334, 2023-10-03)
example/android/app/src/main/ (0, 2023-10-03)
example/android/app/src/main/AndroidManifest.xml (2027, 2023-10-03)
example/android/app/src/main/kotlin/ (0, 2023-10-03)
example/android/app/src/main/kotlin/com/ (0, 2023-10-03)
example/android/app/src/main/kotlin/com/jhomlala/ (0, 2023-10-03)
example/android/app/src/main/kotlin/com/jhomlala/alice_example/ (0, 2023-10-03)
example/android/app/src/main/kotlin/com/jhomlala/alice_example/MainActivity.kt (374, 2023-10-03)
example/android/app/src/main/res/ (0, 2023-10-03)
example/android/app/src/main/res/drawable/ (0, 2023-10-03)
example/android/app/src/main/res/drawable/launch_background.xml (434, 2023-10-03)
example/android/app/src/main/res/mipmap-hdpi/ (0, 2023-10-03)
example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (4489, 2023-10-03)
example/android/app/src/main/res/mipmap-mdpi/ (0, 2023-10-03)
example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (2384, 2023-10-03)
example/android/app/src/main/res/mipmap-xhdpi/ (0, 2023-10-03)
example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (6078, 2023-10-03)
example/android/app/src/main/res/mipmap-xxhdpi/ (0, 2023-10-03)
example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (12347, 2023-10-03)
... ...
# Alice
[![pub package](https://img.shields.io/pub/v/flutter_alice.svg)](https://pub.dev/packages/flutter_alice)
[![pub package](https://img.shields.io/github/license/hautvfami/flutter-alice.svg?style=flat)](https://github.com/hautvfami/flutter-alice)
[![pub package](https://img.shields.io/badge/platform-flutter-blue.svg)](https://github.com/hautvfami/flutter-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
1. Add this to your **pubspec.yaml** file:
```yaml
dependencies:
flutter_alice: ^1.0.1
```
2. Install it
```bash
$ flutter pub get
```
3. Import it
```dart
import 'package:flutter_alice/alice.dart';
```
## Usage
### Alice configuration
1. Create Alice instance:
```dart
Alice alice = Alice();
```
2. Add navigator key to your application:
```dart
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:
```dart
Alice alice = Alice(navigatorKey: yourNavigatorKeyHere);
```
If you need to pass navigatorKey lazily, you can use:
```dart
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:
```dart
Alice alice = Alice(..., darkTheme: true);
```
### HTTP Client configuration
If you're using Dio, you just need to add interceptor.
```dart
Dio dio = Dio();
dio.interceptors.add(alice.getDioInterceptor());
```
If you're using HttpClient from dart:io package:
```dart
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:
```dart
http.get('https://jsonplaceholder.typicode.com/posts').then((response) {
alice.onHttpResponse(response);
});
```
If you're using Chopper. you need to add interceptor:
```dart
chopper = ChopperClient(
interceptors: alice.getChopperInterceptor(),
);
```
If you have other HTTP client you can use generic http call interface:
```dart
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:
```dart
import 'package:flutter_alice/core/alice_http_client_extensions.dart';
import 'package:flutter_alice/core/alice_http_extensions.dart';
```
2. Use extensions:
```dart
http
.post('https://jsonplaceholder.typicode.com/posts', body: body)
.interceptWithAlice(alice, body: body);
```
```dart
httpClient
.postUrl(Uri.parse("https://jsonplaceholder.typicode.com/posts"))
.interceptWithAlice(alice, body: body, headers: Map());
```
近期下载者:
相关文件:
收藏者: