BaseVM class abstract

Implementers

Constructors

BaseVM.new()

Properties

context BuildContext?
上下文
no setter
hashCode int
The hash code for this object.
no setterinherited
onDismissLoading OnDismissLoading?
getter/setter pair
onShowLoading OnShowLoading?
getter/setter pair
pageLifecycle PageLifecycle
页面生命周期
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timers List<Timer>
final

Methods

cancelRequest(CancelToken cancelToken) → void
取消某个网络请求
checkHasPermissions(List<Permission> permissions) Future<bool>
检查是否有权限
createApi<API extends BaseApi>(API api) → API
创建api,这个方法主要是将api绑定到VM中,VM销毁时会去cancel其中的未完成请求
createLifecycleTimer(Duration duration, void callback()) Timer
创建具备ViewModel生周期自动销毁的Timer
dismissLoading() → void
隐藏loading弹框
download({required String urlPath, required dynamic filename, bool isNeedLoading = true, bool isLoadingCancelable = false, String? loadingTxt, Map<String, dynamic>? params, Map<String, dynamic>? body, Options? options, CancelToken? cancelToken, OnSuccess<File>? onSuccess, ProgressCallback? onProgress, OnFailed? onFailed}) → void
下载文件
getDelayCreateDuration() Duration
getString(MultiString multiString) String
根据MultiString获取字符串
hideKeyboard() → void
隐藏输入法
init(BuildContext context, PageLifecycle pageLifecycle) → void
isFinishing() bool
widget生命周期是否没开始或已经结束
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onBackPressed() Future<bool>
返回按钮点击 注意,如果是带有BasePage嵌套BasePage的情况,子BasePage需要override并不执行pop操作 以上提到的BasePage是指BasePageBasePage的子类
onCreate() → void
onCreate生命周期
onDelayCreate() → void
onDestroy() → void
onDestroy生命周期
onPause() → void
onPause生命周期
onResume() → void
onResume生命周期
pop<T extends Object?>({T? result, bool cantPopExit = true}) → void
页面退出,dialog的dismiss cantPopExit 如果不可pop的时候是否退出当前APP,默认是true
push<T>(Widget page, {bool finishCurr = false}) Future<T?>
跳转页面 page 需要跳转的页面 finishCurr 是否需要结束当前页面,注意确认当前页面是否可退出
request<T>({required Future<BaseResp<T>> future, bool isNeedLoading = true, bool isLoadingCancelable = false, String? loadingTxt, bool isShowErrorToast = false, bool isShowErrorDetailToast = false, OnSuccess<T>? onSuccess, OnFailed? onFailed}) → void
同步回调的网络请求
requestPermission(PermissionReq permissionReq) → void
请求权限
showKeyboard(FocusNode focusNode) → void
展示输入法
showLoading({String? loadingTxt, Color? barrierColor, bool barrierDismissible = false, bool cancelable = false}) → void
展示loading弹框 barrierColor 蒙层颜色 barrierDismissible 点击蒙层是否可以消失,默认不行 cancelable 返回按钮或者手势是否可以dismiss,默认不行
showToast(String? msg) → void
展示toast
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited