apex_flutter_plugin 3.0.0-nullsafety.46
apex_flutter_plugin: ^3.0.0-nullsafety.46 copied to clipboard
ApexTeam Flutter Plugin - A simple flutter plugin for ApexTeam fellas which supports http request management, request encryption, request cancellation, ... .
NOTE #
If you are going to use this package in a web application add this script below, before main.dart.js script.
<script src="https://cdnjs.cloudflare.com/ajax/libs/fingerprintjs2/2.1.0/fingerprint2.min.js"></script>
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 #
Make Sure you add EasyLoading.init() to MaterialApp builder parameter like this: builder: EasyLoading.init()
.
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
or just add this pub dependency to your project :
dependencies:
apex_flutter_plugin: <latest-version>
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 :
You can also initialize the config of requests whenever you need just like this :
Api.shared.config = ApiConfig(
'https://jsonplaceholder.typicode.com/posts/',
'1,
'1',
encrypt: false,
debugMode: true);
0. Wrap your MaterialApp with ServerWidget #
ServerWidget(
actions: {
Res: (x) => Res.fromJson(x),
},
config: ApiConfig("https://google.com", "1", "1", debugMode: true),
child: MaterialApp(
home: MyApp(),
),
);
1. ApiConfig Inputs #
Every input parameters are optional except url
which is positional.
Parameters | Data Type | Default Value | Note |
---|---|---|---|
url | String | - | - |
privateVersion | String | - | - |
publicVersion | String | - | - |
encrypt | bool | false | true if you need encryption. |
debugMode | bool | false | true if you need to see some log. |
KeyPairs | KeyPairs | null | different platforms public and secret keys. |
defaultParameters | Map<String, dynamic> | null | this will be added to every one of your requests. |
2. Api makeRequest()
method Inputs #
Every input parameters are optional except request
which is positional.
ServerWidget.of(context).makeRequest
Parameters | Data Type | Default Value | Note |
---|---|---|---|
request | Request | - | See how to create Request object. |
showDialog | bool | - | To show progress dialog if there is a loading widget in ServerWidget |
3. Request Inputs #
Create a new model for every Request which extends Request class.
Parameters | Data Type | Default Value |
---|---|---|
params | Map<String, dynamic> | - |
method | Method | Method.POST |
4. Response Inputs #
Parameters | Data Type | Default Value | Note |
---|---|---|---|
result | Result | - | - |
body | String | - | Server raw response body. |
state | ResponseState | - | One of these ERROR , SUCCESS , UNEXPECTED |
statusCode | num | - | Http request status code whichi is 400, 403, 500, ... |