ai_http 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new52

ai_http #

totem


English Document中文文档

我们的宗旨是:帮助开发者更加便利开发、切身体会编程之美! #

ai_http: #

pub package

*1、支持:RESTful

*2、支持:拦截器

*3、....

ai_http项目中的实战应用flutter sample

1.安装 #

使用当前包作为依赖库

1. 依赖此库 #

在文件 'pubspec.yaml' 中添加

pub package


dependencies:

  ai_http: ^version

或以这种方式添加


  # Http package.
  ai_http:
    git:
      url: https://github.com/pdliuw/ai_http.git

2. 安装此库 #

你可以通过下面的命令行来安装此库


$ flutter pub get


你也可以通过项目开发工具通过可视化操作来执行上述步骤

3. 导入此库 #

现在,在你的Dart编辑代码中,你可以使用:


import 'package:ai_http/ai_http.dart';

2.使用 #

1.全局配置 #

  • 在你的项目入口'main.dart'中配置:


void main() {
  ///
  /// 配置Http
  AiHttp.globalConfig(
    baseUrl: "https://www.baidu.com/",
    requestInterceptor: RequestInterceptorWell(),
    responseInterceptor: ResponseInterceptorWell(),
  );

  runApp(
    ......
  );
}


2.拦截器: #

请求拦截器


    
    ///
    /// RequestInterceptorWell
    class RequestInterceptorWell extends RequestInterceptor {
      @override
      Future<RequestRule> interceptor(RequestRule requestRule) async {
        //do something
    
        return requestRule;
      }
    }


响应拦截器

    
    
    ///
    /// ResponseInterceptorWell
    class ResponseInterceptorWell extends ResponseInterceptor {
      @override
      interceptor(ResponseInterceptorModel responseInterceptorModel) {
        Response response = responseInterceptorModel.response;
        ResponseCallback responseCallback =
            responseInterceptorModel.responseCallback;
        OSError osError = responseInterceptorModel.osError;
    
        //do something
        
        return false;
      }
    }
    

3.请求方式: #

1.Get #


              AiHttp.get(
                requestRule: RequestRule(
                  url: "",
                  headers: {},
                  parameters: {},
                ),
                responseCallback: ResponseCallback(
                  successfulCallback: (ResponseModel successfulModel) {
                    //successful
                    //do something
                  },
                  failureCallback: (ResponseModel failureModel) {
                    //failure
                    //do something
                  },
                ),
              );

2.Post #


              AiHttp.post(
                requestRule: RequestRule(
                  url: "",
                  headers: {},
                  body: {},
                ),
                responseCallback: ResponseCallback(
                  successfulCallback: (ResponseModel successfulModel) {
                    //successful
                    //do something
                  },
                  failureCallback: (ResponseModel failureModel) {
                    //failure
                    //do something
                  },
                ),
              );

3.Delete #


              AiHttp.delete(
                requestRule: RequestRule(
                  url: "",
                  headers: {},
                  parameters: {},
                ),
                responseCallback: ResponseCallback(
                  successfulCallback: (ResponseModel successfulModel) {
                    //successful
                    //do something
                  },
                  failureCallback: (ResponseModel failureModel) {
                    //failure
                    //do something
                  },
                ),
              );

意犹未尽点击,查看更多

待办 #

    1. ......
    1. ......
    1. ......

证书 #


BSD 3-Clause License

Copyright (c) 2020, pdliuw
All rights reserved.

证书

[0.1.1] - ai_http.

  • Update: document

[0.1.0] - ai_http.

  • Fix: something

[0.0.3] - ai_http.

  • Support: Interceptor
  • Update: document
  • Update: example

[0.0.2] - ai_http.

  • Initial: example.

[0.0.1] - ai_http.

  • Initial: Describe initial release.

example/README.md

example #

A new Flutter example application with dart package.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ai_http: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:ai_http/ai_http.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
4
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
52
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+4 0.12.0+4
http_parser ^3.1.3 3.1.3
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
meta 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test