当前位置:网站首页>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
边栏推荐
- How to switch between dual graphics cards of notebook computer
- 在恒泰证券开户怎么样?安全吗?
- [issue 16] golang's one-year experience in developing Purdue Technology
- Format cluster and start cluster
- Fluent learning (5) GridView
- [sg function] 2021 Niuke winter vacation training camp 6 h. winter messenger 2
- The difference between SRAM and DRAM
- 6.2 normalization 6.2.5 third normal form (3NF)
- [15th issue] Tencent PCG background development internship I, II and III (OC)
- Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
猜你喜欢
Blue Bridge Cup -- guess age
IDENTITY
Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
BUUCTF,Misc:LSB
Pyqt5 sensitive word detection tool production, operator's Gospel
Team collaborative combat penetration tool CS artifact cobalt strike
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
MLX90614 driver, function introduction and PEC verification
How to solve win10 black screen with only mouse arrow
随机推荐
6.2 normalization 6.2.5 third normal form (3NF)
[Android reverse] use the DB browser to view and modify the SQLite database (copy the database file from the Android application data directory | use the DB browser tool to view the data block file)
Qtoolbutton - menu and popup mode
Quick one click batch adding video text watermark and modifying video size simple tutorial
Yyds dry goods inventory Prometheus alarm Art
Buuctf, misc: sniffed traffic
How to restore the factory settings of HP computer
Shiftvit uses the precision of swing transformer to outperform the speed of RESNET, and discusses that the success of Vit does not lie in attention!
Data consistency between redis and database
[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
The overseas listing of Shangmei group received feedback, and brands such as Han Shu and Yiye have been notified for many times and received attention
[sg function] lightoj Partitioning Game
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Pyqt5 sensitive word detection tool production, operator's Gospel
The difference between SRAM and DRAM
How to connect a laptop to a projector
Common mode interference of EMC
1068. Consolidation of ring stones (ring, interval DP)
Buuctf, web:[geek challenge 2019] buyflag
Hcip day 12 notes