当前位置:网站首页>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
边栏推荐
- Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"
- Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
- 4 environment construction -standalone ha
- Can you draw with turtle?
- Comparable interface and comparator interface
- [sg function] lightoj Partitioning Game
- [Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)
- Fashion cloud interview questions series - JS high-frequency handwritten code questions
- Summary of basic knowledge of exception handling
- Creation of the template of the password management software keepassdx
猜你喜欢
Esp-idf turns off serial port log output.
A preliminary study on the middleware of script Downloader
Opengauss database log management guide
[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)
Summary of fluent systemchrome
Harbor integrated LDAP authentication
Data consistency between redis and database
X Opencv feature point detection and matching
Pointer concept & character pointer & pointer array yyds dry inventory
Can you draw with turtle?
随机推荐
webAssembly
The difference between single power amplifier and dual power amplifier
How to solve the problem of requiring a password when accessing your network neighborhood on your computer
STM32 multi serial port implementation of printf -- Based on cubemx
The 2022 global software R & D technology conference was released, and world-class masters such as Turing prize winners attended
Buuctf, misc: sniffed traffic
Op amp related - link
Classification and extension of OC
[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)
. Net ADO splicing SQL statement with parameters
Creation of the template of the password management software keepassdx
Hcip day 14 notes
Simple solution of m3u8 file format
Sow of PMP
C summary of knowledge point definitions, summary notes
Go error collection | talk about the difference between the value type and pointer type of the method receiver
Hcip day 12 notes
LeetCode 1647. Minimum deletion times of unique character frequency
To rotate 90 degrees clockwise and modify the video format
[issue 16] golang's one-year experience in developing Purdue Technology