shindenshin 0.3.6
shindenshin: ^0.3.6 copied to clipboard
Layer communication package. It helps to develop data layer with models and API connectors, which will be used by BLoC to build UI.
Basics #
This package includes all necessary basics to make comunications between UI, BL and Data layers.
Used dependencies:
- dio
- hive
- bloc
- equatable
ApiClient #
This is a singleton class that contains basic REST methods and a little auth logic.
It should be initialized before used.
ApiClient inits itself automatically in Store constructor (see below).
init method has the following arguments:
releaseBaseHost- URI which will be used in release build;forceUseReleaseHost- tells it to use release uri even in debug mode (default false);androidDegubHost- URI for Android Emulator in debug mode (default 10.0.2.2)
BaseModel and BaseModalApi #
These two are useful for mapping backend entities to your flutter application.
BaseModelApi can request a list (or paginatedList) of items, retreive a single item by id, create a new item and update or delete an existing one.
You should implement fromJson method and the url field which is a relative path (e.g. 'products', 'orders' etc.).
rootList parameter set to true is needed if response's data doesn't have a pagination.
BaseStore #
Is needed to create a centralized Store which contains all the repositories.
BaseStore is Subscriptable so you can call subscribe(fn) and notify(event) methods to help repos communicate with each other.
BaseRepo #
This class is needed to create your repositories. It's also Subscriptable.
All the repos should be initialized in Store's constructor and pass Store instance to super.