flutter_spi 0.1.1

Flutter Android iOS

Flutter Widgets that make it easy to use the dio package. contain the Logger Plugin、Error Plugin、Serialize Plugin、Dio Manager.

Flutter Spi #

A Dio NetWork plugin

How to Use #

# add this line to your dependencies
flutter_spi: ^0.1.1

Import #

import 'package:flutter_spi/flutter_spi.dart';

RxDart Extension #

extension PGSpiRx on PGSpi {
  // object stream
  Stream<T> mapSpiObject<T>({String path}) => this
      .responseSpiJson(path: path)
      .asStream()
      .map((value) => BaseBeanEntity.fromJson(value).object<T>());
  // objects stream
  Stream<List<T>> mapSpiObjects<T>({String path}) => this
      .responseSpiJsons(path: path)
      .asStream()
      .map((value) => BaseBeanEntity.fromJsonList(value).objects<T>());
}

Bean #

class EntityFactory {
  static T generateOBJ<T>(json) {
    if (1 == 0) {
      return null;
    } else if (T.toString() == "News") {
      return News.fromJson(json) as T;
    } else {
      return null;
    }
  }
}

Example #

PGSpi(AccountAPI.login(
            {
                "type": "top",
                "key": "8093f06289133b469be6ff7ab6af1aa9"
            }
        )
    )
    .mapSpiObjects<News>(path: "data")
    .listen(
        (value) => print(value[0].authorName),
        onError: (e) {
            print((e.error as PGSpiError).message);
      },
    );
classdescription
pg_spiSpi
pg_spi_dioDio Response Convert
pg_spi_errorError
pg_spi_loggerLogger
pg_spi_managerNetWork Manage
pg_spi_responseResponse Convert
pg_spi_targetApi Enum

License #

MIT License

1
likes
90
pub points
0%
popularity

Flutter Widgets that make it easy to use the dio package. contain the Logger Plugin、Error Plugin、Serialize Plugin、Dio Manager.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

chinafengjun@gmail.com

License

MIT (LICENSE)

Dependencies

dio, flutter

More

Packages that depend on flutter_spi