当前位置:网站首页>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
边栏推荐
- Unsafe and CAS principle
- Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"
- Blue Bridge Cup -- Mason prime
- Data consistency between redis and database
- Quick one click batch adding video text watermark and modifying video size simple tutorial
- Mindmanager2022 serial number key decompression installer tutorial
- Go error collection | talk about the difference between the value type and pointer type of the method receiver
- How to quickly build high availability of service discovery
- Qtoolbutton - menu and popup mode
- [golang] leetcode intermediate - alphabetic combination of island number and phone number
猜你喜欢

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!

How to understand the gain bandwidth product operational amplifier gain

Pooling idea: string constant pool, thread pool, database connection pool

Apple released a supplementary update to MacOS Catalina 10.15.5, which mainly fixes security vulnerabilities

Interpretation of corolla sub low configuration, three cylinder power configuration, CVT fuel saving and smooth, safety configuration is in place

Pyqt5 sensitive word detection tool production, operator's Gospel

540. Single element in ordered array

Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
![[note] IPC traditional interprocess communication and binder interprocess communication principle](/img/f6/36c28df02198539e27352e3cdf4ba6.jpg)
[note] IPC traditional interprocess communication and binder interprocess communication principle

Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
随机推荐
Interesting 10 CMD commands
File copy method
Programming language (2)
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
How to restore the factory settings of HP computer
Text replacement demo
Gorilla/mux framework (RK boot): add tracing Middleware
Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
Buuctf, misc: n solutions
Recursion and recursion
Pandaoxi's video
NPM script
2022.02.13
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Design of logic level conversion in high speed circuit
[note] IPC traditional interprocess communication and binder interprocess communication principle
Buuctf, misc: sniffed traffic
LeetCode 1647. Minimum deletion times of unique character frequency
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Scratch uses runner Py run or debug crawler