当前位置:网站首页>Live app source code, jump to links outside the station or jump to pages inside the platform
Live app source code, jump to links outside the station or jump to pages inside the platform
2022-07-03 23:06:00 【Cloudleopard network technology】
live broadcast app Source code , Jump to the relevant code of the implementation of links outside the station or jump pages inside the platform
});
} else {
await Future.delayed(Duration(milliseconds: 10));
showLoading();
}
}
@override void dispose() {
super.dispose();
setIsDispose(true);
viewModel.showLoadingFun = null;
viewModel.dismissLoadingFun = null;
}
}
abstract class BaseViewModel extends ChangeNotifier with BaseViewModelInterface, NavigatorMixin, ToastMixin, SharePreferenceMixin, EventBusMixin, DataBaseMixin {
int _loadNum = 0;
int _minLoadNum = 1;
late BuildContext context;
late M model;
bool _isDispose = false;
bool get isDispose => _isDispose;
int needLoadingRequestCount = 0;
bool isLoading = false;
Function()? showLoadingFun;
Function? dismissLoadingFun;
static bool isNeedCatchError = false; set minLoadNum(int value) {
_minLoadNum = value;
}
set loadNum(int value) {
_loadNum = value;
}
int get loadNum {
return _loadNum;
}
void notifyPage() {
if (!_isDispose) {
loadNum++;
print(">loadNum:$loadNum"); if (_loadNum >= _minLoadNum) {
print(">notifyListeners");
notifyListeners();
}
}
}
@override void init() {
model = getIt.get();
setContext(context);
setIsDispose(false);
}
void showLoading(bool isNeedLoading) {
if (isNeedLoading) {
needLoadingRequestCount++; if (!isLoading) {
isLoading = true; if (showLoadingFun != null) {
showLoadingFun!.call();
}
showLoadingFun?.call();
}
}
}
void dismissLoading(bool isNeedLoading) {
if (isNeedLoading) {
needLoadingRequestCount–; if (needLoadingRequestCount == 0) {
isLoading = false; if (dismissLoadingFun != null) {
dismissLoadingFun!.call();
}
dismissLoadingFun?.call();
}
}
}
/// Initiate network request , Handle exceptions at the same time ,loading void sendRequest(Future future, FutureOr onValue(T value),
{
Function(Exception e)? error, bool isNeedLoading = false}) {
showLoading(isNeedLoading); future.then((t) {
dismissLoading(isNeedLoading);
onValue(t);
}); if (isNeedCatchError) {
future.catchError((e) {
dismissLoading(isNeedLoading);
print("====>error:$e"); if (error != null) {
error(e);
}
});
}
}
@override void dispose() {
super.dispose();
_isDispose = true;
setIsDispose(_isDispose);
}
}
@injectable class LoginViewModel extends BaseViewModel {
@factoryMethod LoginViewModel();
String loginName = “”;
String psw = “”; /// Sign in void login() {
if (loginName.isEmpty) {
showToast(“ Login account cannot be empty ”);
} else if (psw.isEmpty) {
showToast(“ The login password cannot be empty ”);
} else {
sendRequest(model.login(loginName, psw), (value) {
if (value.errorCode == 0) {
value.data?.let((it) {
UserInfoSp.getInstance().uid = it.id ?? 0;
UserInfoSp.getInstance().token = it.token ?? “”;
UserInfoSp.getInstance().userName = it.username ?? “”;
});
pop();
push(MainPage());
} else {
showToast(value.errorMsg!);
}
}, isNeedLoading: true);
}
}
}
That's all live broadcast app Source code , Jump to the relevant code of the implementation of links outside the station or jump pages inside the platform , More content welcome to follow the article
边栏推荐
- Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
- Mindmanager2022 serial number key decompression installer tutorial
- Flutter internationalized Intl
- The 2022 global software R & D technology conference was released, and world-class masters such as Turing prize winners attended
- Programming language (1)
- Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
- Hcip day 14 notes
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- Es6~es12 knowledge sorting and summary
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
猜你喜欢

Schematic diagram of crystal oscillator clock and PCB Design Guide

Es6~es12 knowledge sorting and summary
![[template summary] - binary search tree BST - Basics](/img/78/782129abea06c8e3bef69a121cbce0.jpg)
[template summary] - binary search tree BST - Basics

3 environment construction -standalone

How the computer flushes the local DNS cache

User login function: simple but difficult

Unity shader visualizer shader graph

Qtoolbutton available signal
![[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)](/img/1d/044e81258db86cf34eddd3b8f5cf90.jpg)
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)

STM32 multi serial port implementation of printf -- Based on cubemx
随机推荐
Arc135 partial solution
Codeforces Round #768 (Div. 1)(A-C)
LeetCode 1646. Get the maximum value in the generated array
C summary of knowledge point definitions, summary notes
Yyds dry goods inventory Spring Festival "make" your own fireworks
Pat grade A - 1164 good in C (20 points)
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Interesting 10 CMD commands
在恒泰证券开户怎么样?安全吗?
[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)
QT creator source code learning note 05, how does the menu bar realize plug-in?
AST (Abstract Syntax Tree)
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
Maxwell equation and Euler formula - link
Shell script three swordsman awk
C3p0 connection MySQL 8.0.11 configuration problem
Take you to master the formatter of visual studio code
Pan Yueming helps Germany's Rochester Zodiac custom wristwatch
string
This time, thoroughly understand bidirectional data binding 01