fast_mvvm library

Classes

BaseEntity
基类Entity JSON数据实体
BaseListEntity<T>
BaseListViewModel<M extends BaseModel, E extends BaseEntity, I>
基类 ListVM
BaseModel
基类Model 具体实现API
BaseViewModel<M extends BaseModel, E extends BaseEntity>
基类 VM
ChangeNotifierProvider<T extends ChangeNotifier?>
Listens to a ChangeNotifier, expose it to its descendants and rebuilds dependents whenever ChangeNotifier.notifyListeners is called.
ChangeNotifierProxyProvider<T, R extends ChangeNotifier?>
A ChangeNotifierProvider that builds and synchronizes a ChangeNotifier with external values.
ChangeNotifierProxyProvider0<R extends ChangeNotifier?>
A ChangeNotifierProvider that builds and synchronizes a ChangeNotifier with external values.
ChangeNotifierProxyProvider2<T, T2, R extends ChangeNotifier?>
A ChangeNotifierProvider that builds and synchronizes a ChangeNotifier with external values.
ChangeNotifierProxyProvider3<T, T2, T3, R extends ChangeNotifier?>
A ChangeNotifierProvider that builds and synchronizes a ChangeNotifier with external values.
ChangeNotifierProxyProvider4<T, T2, T3, T4, R extends ChangeNotifier?>
A ChangeNotifierProvider that builds and synchronizes a ChangeNotifier with external values.
ChangeNotifierProxyProvider5<T, T2, T3, T4, T5, R extends ChangeNotifier?>
A ChangeNotifierProvider that builds and synchronizes a ChangeNotifier with external values.
ChangeNotifierProxyProvider6<T, T2, T3, T4, T5, T6, R extends ChangeNotifier?>
A ChangeNotifierProvider that builds and synchronizes a ChangeNotifier with external values.
Consumer<T>
Obtains Provider<T> from its ancestors and passes its value to builder.
Consumer2<A, B>
Obtains Provider<T> from its ancestors and passes its value to builder.
Consumer3<A, B, C>
Obtains Provider<T> from its ancestors and passes its value to builder.
Consumer4<A, B, C, D>
Obtains Provider<T> from its ancestors and passes its value to builder.
Consumer5<A, B, C, D, E>
Obtains Provider<T> from its ancestors and passes its value to builder.
Consumer6<A, B, C, D, E, F>
Obtains Provider<T> from its ancestors and passes its value to builder.
DataResponse<T>
接口数据 响应
DeferredInheritedProvider<T, R>
An InheritedProvider where the object listened is not the object emitted.
EmptyIntactWidget
用于当 List 或者 Grid 空的时候生成完整的整页面 如果在ListView 里面用
FastMvvm
FutureProvider<T>
Listens to a Future and exposes its result to child and its descendants.
InheritedContext<T>
A BuildContext associated to an InheritedProvider.
InheritedProvider<T>
A generic implementation of an InheritedWidget.
ListenableProvider<T extends Listenable?>
Listens to a Listenable, expose it to its descendants and rebuilds dependents whenever the listener emits an event.
ListenableProxyProvider<T, R extends Listenable?>
A variation of ListenableProvider that builds its value from values obtained from other providers.
ListenableProxyProvider0<R extends Listenable?>
A variation of ListenableProvider that builds its value from values obtained from other providers.
ListenableProxyProvider2<T, T2, R extends Listenable?>
A variation of ListenableProvider that builds its value from values obtained from other providers.
ListenableProxyProvider3<T, T2, T3, R extends Listenable?>
A variation of ListenableProvider that builds its value from values obtained from other providers.
ListenableProxyProvider4<T, T2, T3, T4, R extends Listenable?>
A variation of ListenableProvider that builds its value from values obtained from other providers.
ListenableProxyProvider5<T, T2, T3, T4, T5, R extends Listenable?>
A variation of ListenableProvider that builds its value from values obtained from other providers.
ListenableProxyProvider6<T, T2, T3, T4, T5, T6, R extends Listenable?>
A variation of ListenableProvider that builds its value from values obtained from other providers.
ListOrGridEmpty
内容容器 判断 List 或者 Grid 是否为空 显示内容或加载空视图
MultiProvider
A provider that merges multiple providers into a single linear widget tree. It is used to improve readability and reduce boilerplate code of having to nest multiple layers of providers.
Provider<T>
A Provider that manages the lifecycle of the value it provides by delegating to a pair of Create and Dispose.
ProviderBinding
ProxyProvider<T, R>
A provider that builds a value based on other providers.
ProxyProvider0<R>
A provider that builds a value based on other providers.
ProxyProvider2<T, T2, R>
A provider that builds a value based on other providers.
ProxyProvider3<T, T2, T3, R>
A provider that builds a value based on other providers.
ProxyProvider4<T, T2, T3, T4, R>
A provider that builds a value based on other providers.
ProxyProvider5<T, T2, T3, T4, T5, R>
A provider that builds a value based on other providers.
ProxyProvider6<T, T2, T3, T4, T5, T6, R>
A provider that builds a value based on other providers.
ReassembleHandler
If you need your provider to be notified when 'Hot Reload' occurs, use this class
Selector<A, S>
An equivalent to Consumer that can filter updates by selecting a limited amount of values and prevent rebuild if they don't change.
Selector0<T>
A base class for custom Selector.
Selector2<A, B, S>
An equivalent to Consumer that can filter updates by selecting a limited amount of values and prevent rebuild if they don't change.
Selector3<A, B, C, S>
An equivalent to Consumer that can filter updates by selecting a limited amount of values and prevent rebuild if they don't change.
Selector4<A, B, C, D, S>
An equivalent to Consumer that can filter updates by selecting a limited amount of values and prevent rebuild if they don't change.
Selector5<A, B, C, D, E, S>
An equivalent to Consumer that can filter updates by selecting a limited amount of values and prevent rebuild if they don't change.
Selector6<A, B, C, D, E, F, S>
An equivalent to Consumer that can filter updates by selecting a limited amount of values and prevent rebuild if they don't change.
StreamProvider<T>
Listens to a Stream and exposes its content to child and descendants.
ValueListenableProvider<T>
Listens to a ValueListenable and exposes its current value.
ViewConfig<VM extends BaseViewModel<BaseModel, BaseEntity>>
view层 配置用类 配置全局默认状态页
ViewStateBusyWidget
加载中
ViewStateButton
公用Button
ViewStateEmptyWidget
页面无数据
ViewStateNotifier
状态通知 跨页面通知数据需要变动
ViewStateUnAuthWidget
页面未授权
ViewStateWidget
基础Widget

Enums

MaxIndex
ViewModelState
ViewModel的状态 控制页面基础显示
ViewSizeType
空Widget大小类型

Mixins

BaseRepo
基类的API 声明API
BaseView<VM extends BaseViewModel<BaseModel, BaseEntity>>
基类 view 扩展StatelessWidget
BaseViewOfState<T extends StatefulWidget, VM extends BaseViewModel<BaseModel, BaseEntity>>
基类 state 扩展StatefulWidgetState

Extensions

ReadContext on BuildContext
Exposes the read method.
SelectContext on BuildContext
Adds a select method on BuildContext.
WatchContext on BuildContext
Exposes the watch method.

Properties

list Map<int, BaseViewModel<BaseModel, BaseEntity>>
getter/setter pair

Functions

addModel({required List<BaseModel> list}) → void
添加Model
availableCNP<T extends BaseViewModel<BaseModel, BaseEntity>>(BuildContext context, ViewConfig<T> changeNotifier, {required Widget? child}) ChangeNotifierProvider<ChangeNotifier?>
获取可用的监听 ChangeNotifierProvider.value 或者 ChangeNotifierProvider
changerStateCheck(int state) ViewStateNotifier
验证是否需要变化
changerStateGet(int state) → _ViewStateNotifier
获取状态配置
changerStateUpdate(int state, {bool notifier = true}) → void
更新页面状态
getModelGlobal<M extends BaseModel>() → M
全局Model
getVM<T extends ChangeNotifier>(BuildContext ctx, {bool listen = false}) → T
得到通知者
initMVVM<VM extends BaseViewModel<BaseModel, BaseEntity>>(List<BaseModel> models, {int initPage = 1, DataFromNetworkOrDatabase? dataOfHttpOrData, VSBuilder<VM>? busy, VSBuilder<VM>? empty, VSBuilder<VM>? error, VSBuilder<VM>? unAuthorized, VSBuilder<VM>? listDataEmpty, ResetRefreshState? resetRefreshState, FinishRefresh? finishRefresh, ResetLoadState? resetLoadState, FinishLoad? finishLoad, ControllerBuild? controllerBuild, num? height, num? width}) → void
初始化 配置初始页面全局状态页
initPageSize(double? width, double? height) → void
初始化页面大小 注意适配宽高 还有标题栏高度
statusOrViewDisplay({required Widget? state(), required Widget view()}) Widget
状态或视图显示
vmEmptyView<T extends BaseViewModel<BaseModel, BaseEntity>>({required dynamic builder(T vm), bool isEmpty(T vm)?, Widget? nullChild}) Widget

Typedefs

ControllerBuild = dynamic Function()
上拉加载 下拉刷新的控制器
Create<T> = T Function(BuildContext context)
A function that creates an object of type T.
DataFromNetworkOrDatabase = bool Function(BaseViewModel<BaseModel, BaseEntity> vm)
数据来源 网络或者数据库 true : 网络 --- false :数据库 场景 网络无连接 页面数据缓存在数据库 切换数据来源,改从数据库取数据
DeferredStartListening<T, R> = VoidCallback Function(InheritedContext<R?> context, void setState(R value), T controller, R? value)
A callback used to handle the subscription of controller.
Dispose<T> = void Function(BuildContext context, T value)
A function that disposes an object of type T.
ErrorBuilder<T> = T Function(BuildContext context, Object? error)
A callback used to build a valid value from an error.
FinishLoad = void Function(dynamic controller, {required bool noMore, required bool success})
上拉加载 下拉刷新 完成加载方法
FinishRefresh = void Function(dynamic controller, {required bool noMore, required bool success})
上拉加载 下拉刷新 完成刷新方法
Locator = T Function<T>()
A generic function that can be called to read providers, without having a reference on BuildContext.
ProviderBuilder<R> = Widget Function(BuildContext context, R value, Widget child)
ProxyProviderBuilder<T, R> = R Function(BuildContext context, T value, R? previous)
ProxyProviderBuilder2<T, T2, R> = R Function(BuildContext context, T value, T2 value2, R? previous)
ProxyProviderBuilder3<T, T2, T3, R> = R Function(BuildContext context, T value, T2 value2, T3 value3, R? previous)
ProxyProviderBuilder4<T, T2, T3, T4, R> = R Function(BuildContext context, T value, T2 value2, T3 value3, T4 value4, R? previous)
ProxyProviderBuilder5<T, T2, T3, T4, T5, R> = R Function(BuildContext context, T value, T2 value2, T3 value3, T4 value4, T5 value5, R? previous)
ProxyProviderBuilder6<T, T2, T3, T4, T5, T6, R> = R Function(BuildContext context, T value, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, R? previous)
ResetLoadState = void Function(dynamic controller)
上拉加载 下拉刷新 重置加载状态方法
ResetRefreshState = void Function(dynamic controller)
上拉加载 下拉刷新 重置刷新状态方法
ShouldRebuild<T> = bool Function(T previous, T next)
Used by providers to determine whether dependents needs to be updated when the value exposed changes
StartListening<T> = VoidCallback Function(InheritedContext<T?> element, T value)
A callback used to start the listening of an object and return a function that cancels the subscription.
UpdateShouldNotify<T> = bool Function(T previous, T current)
A function that returns true when the update from previous to current should notify listeners, if any.
VMBuilder<T extends BaseViewModel<BaseModel, BaseEntity>> = Widget Function(BuildContext context, T viewModel, Widget? child, Widget? state)
page build 的替换方法
VSBuilder<T extends BaseViewModel<BaseModel, BaseEntity>> = Widget Function(T vm)
page 状态页

Exceptions / Errors

ProviderNotFoundException
The error that will be thrown if Provider.of fails to find a Provider as an ancestor of the BuildContext used.
ProviderNullException
Called Provider.of<T> instead of Provider.of<T?> but the provider returned null.
UnAuthorizedException
用于未登录等权限不够,需要跳转授权页面