apex_flutter_plugin 1.0.21

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

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, ...

1.0.21 #

Using custom BrowserClient with universal_html import.

1.0.21-dev.11 #

Using BrowserClient to solve Unsupported operation: Platform._version error.

1.0.20 #

You can upload blob data of a file on web platform by sending blobData using uploadFile method.

1.0.19 #

Had a breaking change!

  • Pass an instance of IsolateModel to makeRequest method.

1.0.19-dev.2.3 #

Added isolateLoader to makeRequest within isolates.

1.0.18 #

CancelToken null checker for uploading files!

1.0.17 #

Upload cancelToken and default timeout for ApiConfig.

1.0.15 #

Retrieve uploaded bytes and total bytes to calculate the progress.

1.0.14 #

Changed pubspec homepage and dartdoc version.

1.0.12 #

A little code cleanup!

1.0.11 #

Bug fixed.

1.0.10 #

Minor bug fixed (connectivity check on web platform).

1.0.9 #

added connectivity dependency for checking mobile connection to the network.

1.0.8-dev.2 #

default parameters now are modifiable!

1.0.8-dev.0 #

No need to use response.result.params['key']. use response.result['key'] instead.

1.0.7 #

Now you can pass url to makeRequest, uploadFile(s) methods in Api singleton and it will use this url instead of ApiConfig's url.

1.0.6-alpha.1 #

  • Api Stream is outdated.

1.0.5 #

  • Bugs fixed!

1.0.4 #

  • Init

example/lib/main.dart

import 'dart:convert';

import 'package:apex_flutter_plugin/api/api.dart';
import 'package:apex_flutter_plugin/api/config.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:quill_delta/quill_delta.dart';

void main() {
  debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
  runApp(MaterialApp(
    theme: ThemeData(fontFamily: 'IRANSans'),
    home: MyApp(),
  ));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _fingerprint = 'Unknown';
  String _androidId = 'Unknown';
  String _hashUID = 'Unknown';

  @override
  void initState() {
    Api.shared.config = ApiConfig(
        '',
        encrypt: false,
        debugMode: true);

    super.initState();
//    initPlatformState();
  }

//  Future<void> initPlatformState() async {
//    String fingerprint, androidId, hashUID;
//    try {
//      fingerprint = await ApexFlutterPlugin.fingerprint();
//      androidId = await ApexFlutterPlugin.androidId();
//      hashUID = await ApexFlutterPlugin.hashUID();
//    } on PlatformException {
//      fingerprint = 'Failed to get fingerprint.';
//    }
//    if (!mounted) return;
//
//    setState(() {
//      _fingerprint = fingerprint;
//      _androidId = androidId;
//      _hashUID = hashUID;
//    });
//  }

  String _text = "wtf";
  int _index = 0;

  Delta getDelta(String doc) {
    return Delta.fromJson(json.decode(utf8.decode(base64Decode(doc))) as List);
  }

  @override
  Widget build(BuildContext context) {
    var _fontStyle =
    TextStyle(fontFamily: "IRANSans", fontSize: 16, color: Colors.black);

    var _codeStyle = TextStyle(
      fontFamily: "IRANSans",
      fontSize: 18 * 6 / 7,
      decorationStyle: TextDecorationStyle.dashed,
      locale: Locale("en"),
    );
    var _linkStyle = TextStyle(color: Colors.blue);
    var _quoteStyle = TextStyle(color: Colors.blueGrey);

    return Scaffold(
      body: ListView(
        children: [
//          Directionality(
//            textDirection: TextDirection.rtl,
//            child: ZefyrTheme(
//              data: ZefyrThemeData(
//                  attributeTheme: AttributeTheme(
//                      bold: _fontStyle,
//                      italic: _fontStyle,
//                      numberList: BlockTheme(textStyle: _fontStyle),
//                      heading3: LineTheme(
//                          padding: EdgeInsets.only(top: 10),
//                          textStyle: _fontStyle),
//                      heading2: LineTheme(
//                          padding: EdgeInsets.only(top: 10),
//                          textStyle: _fontStyle),
//                      heading1: LineTheme(
//                          padding: EdgeInsets.only(top: 10),
//                          textStyle: _fontStyle),
//                      bulletList: BlockTheme(textStyle: _fontStyle),
//                      quote: BlockTheme(
//                        textStyle: _quoteStyle,
//                      ),
//                      link: _linkStyle,
//                      code: BlockTheme(textStyle: _codeStyle)),
//                  indentWidth: 16,
//                  defaultLineTheme: LineTheme(
//                    textStyle: _fontStyle,
//                    padding: EdgeInsets.only(top: 10, bottom: 5),
//                  )),
//              child: ZefyrView(
//                attrDelegate: CustomAttrDelegate(),
//                document: NotusDocument.fromDelta(getDelta(
//                    "W3siaW5zZXJ0IjoiVWRoZGJk2KjYqtio2KrbjNiq24zZiFxu2K7YqNiu2KjYqtiq2KjYp9uMZGhoZHZkIGQgaGRqZGhkYiBkIGhkaGRoZCJ9LHsiaW5zZXJ0IjoiXG4iLCJhdHRyaWJ1dGVzIjp7ImJsb2NrIjoiY29kZSJ9fSx7Imluc2VydCI6ImhkaGRuIn0seyJpbnNlcnQiOiJcbiIsImF0dHJpYnV0ZXMiOnsiYmxvY2siOiJxdW90ZSJ9fSx7Imluc2VydCI6ImtkamQiLCJhdHRyaWJ1dGVzIjp7ImEiOiJodHRwczovL2dvb2dsZS5jb20ifX0seyJpbnNlcnQiOiJcbiJ9XQ==")),
//                imageDelegate: CustomImageDelegate(onImageClick: (url) {}),
//              ),
//            ),
//          ),
//        ],
          RaisedButton(
            onPressed: () async {
              var file =
              await ImagePicker.pickImage(source: ImageSource.gallery);
              Api.shared.uploadFile('file', file.path, url: 'https://gooyaan.ir/uploadFile.php').then((
                  response) {
                setState(() {
                  _text = response.body;
                });
              });
            },
            child: Text("FINGERPRINT" +
                _fingerprint +
                "\r\nandroidID" +
                _androidId.length.toString() +
                "\r\nhashUID" +
                _hashUID),
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  apex_flutter_plugin: ^1.0.21

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:apex_flutter_plugin/apex_flutter_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
64
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
76
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform ios

Because:

  • package:apex_flutter_plugin/apex_flutter_plugin.dart that declares support for platforms: android

Package does not support Flutter platform linux

Because:

  • package:apex_flutter_plugin/apex_flutter_plugin.dart that declares support for platforms: android

Package does not support Flutter platform macos

Because:

  • package:apex_flutter_plugin/apex_flutter_plugin.dart that declares support for platforms: android

Package does not support Flutter platform web

Because:

  • package:apex_flutter_plugin/apex_flutter_plugin.dart that declares support for platforms: android

Package does not support Flutter platform windows

Because:

  • package:apex_flutter_plugin/apex_flutter_plugin.dart that declares support for platforms: android

Package not compatible with SDK dart

Because:

  • apex_flutter_plugin that is a package requiring null.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://gitlab.com/1839491/apexflutterlogin was unreachable.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (dartdoc).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
connectivity ^0.4.8+6 0.4.9
dartdoc ^0.31.0 0.31.0 0.32.1
encrypt ^4.0.0 4.0.2
flutter 0.0.0
flutter_web_plugins 0.0.0
http ^0.12.1 0.12.1
http_parser ^3.1.4 3.1.4
pedantic ^1.9.0 1.9.0 1.9.1
pointycastle ^1.0.2 1.0.2
universal_html ^1.2.3 1.2.3
Transitive dependencies
_fe_analyzer_shared 5.0.0
analyzer 0.39.12
args 1.6.0
asn1lib 0.6.5
async 2.4.2
charcode 1.1.3
cli_util 0.1.4 0.2.0
clock 1.0.1
collection 1.14.12 1.14.13
connectivity_for_web 0.3.0
connectivity_macos 0.1.0+3
connectivity_platform_interface 1.0.6
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
file 5.2.1
glob 1.2.0
html 0.14.0+3
intl 0.16.1
js 0.6.2
logging 0.11.4
markdown 2.1.5
matcher 0.12.8
meta 1.1.8 1.2.1
mustache 1.1.1
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
path 1.7.0
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
pub_semver 1.4.4
quiver 2.1.3
resource 2.1.7
sky_engine 0.0.99
source_span 1.7.0
stack_trace 1.9.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
universal_io 1.0.1
vector_math 2.0.8 2.1.0-nullsafety
watcher 0.9.7+15
yaml 2.2.1
zone_local 0.1.2
Dev dependencies
build_runner any
build_test any
build_web_compilers any
flutter_test