apex_flutter_plugin 1.0.34

Flutter Android

ApexTeam Flutter Plugin - A simple flutter plugin for ApexTeam fellas which supports http request management, request encryption, request cancellation, ... .

Apex Flutter Plugin #

A simple flutter plugin for ApexTeam fellas which supports http request management, request encryption, request cancellation, ... .

Getting Started #

Here we are! lets get started <3

Table of Contents #

  • Installation
  • Usage

Installation #

Send your gitlab id to 1839491@gmail.com so I can add you to this project as a member. Then make sure you have added this snippet in your pubspec.yaml under dependencies in the tree :

apex_flutter_plugin:
    git:
      url: https://gitlab.com/1839491/apexflutterlogin.git
      path: apex_flutter_plugin

After that run flutter packages get and flutter packages upgrade to get the last version of the dependency.

Usage #

Code snippet for making a new request :

Note: Api is a singleton! so be careful with changing its config.

CancellationToken token = new CancellationToken(); //in case you need to cancel a ongoing request
            Api.shared
                .makeRequest(Request({"first":"second"}, method: Method.GET),
                    cancelToken: token)
                .then((response) {
              setState(() {
                _text = response.body;
              });
            }).catchError((e) {
              if (e is OperationCanceledError) {
                print(e.toString());
              } else if (e is TimeoutException) {
                print(e.toString());
              } else {
                print(e.toString());
              }
            });
token.cancel("cancel this"); //whenever you need to cancel the request

You can also initialize the config of requests whenever you need just like this :


Api.shared.config = ApiConfig(
        "https://jsonplaceholder.typicode.com/posts/1",
        encrypt: false,
        debugMode: true,
        secretKey: Constants.CRYPTO_SECRET_KEY);

1. ApiConfig Inputs #

Every input parameters are optional except url which is positional.

ParametersData TypeDefault ValueNote
urlString--
encryptboolfalsetrue if you need encryption.
debugModeboolfalsetrue if you need to see some log.
publicKeyStringnullRSA public key.
secretKeyStringnullAES secret key.
defaultParametersMap<String, dynamic>nullthis will be added to every one of your requests.

2. Api makeRequest() method Inputs #

Every input parameters are optional except request which is positional.

ParametersData TypeDefault ValueNote
requestRequest-See how to create Request object.
timeLimitDuration-If request future does not complete before timeLimit has passed, the onTimeout action is executed instead, and its result (whether it returns or throws) is used as the result of the returned future.
timeRetryDurationconst Duration(milliseconds: 100)-
onTimeOutOnTimeOut-http OnTimeOut
cancelTokenCancellationToken--
encodingEncoding-The response body encoding. you can pass convert.Encoding.getByName("utf-8")
headersMap<String, String>-The request headers

3. Request Inputs #

ParametersData TypeDefault Value
paramsMap<String, dynamic>-
methodMethodMethod.POST

4. Response Inputs #

ParametersData TypeDefault ValueNote
resultResult--
bodyString-Server raw response body.
stateResponseState-One of these ERROR, SUCCESS, UNEXPECTED
statusCodenum-Http request status code whichi is 400, 403, 500, ...
3
likes
70
pub points
70%
popularity

Publisher

packs.apexteam.net

ApexTeam Flutter Plugin - A simple flutter plugin for ApexTeam fellas which supports http request management, request encryption, request cancellation, ... .

Repository (GitLab)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

connectivity, dartdoc, encrypt, flutter, flutter_web_plugins, http, http_parser, pedantic, pointycastle, universal_html

More

Packages that depend on apex_flutter_plugin