当前位置:网站首页>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
边栏推荐
- Weekly leetcode - nc9/nc56/nc89/nc126/nc69/nc120
- Fashion cloud interview questions series - JS high-frequency handwritten code questions
- Blue Bridge Cup -- guess age
- . Net ADO splicing SQL statement with parameters
- Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
- Mindmanager2022 serial number key decompression installer tutorial
- Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
- File copy method
- Unity shader visualizer shader graph
- [note] glide process and source code analysis
猜你喜欢

Sort merge sort

User login function: simple but difficult

320. Energy Necklace (ring, interval DP)

How to quickly build high availability of service discovery
![[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)](/img/6e/3ffa91154a718b6ace6c8ca87c5995.jpg)
[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)

540. Single element in ordered array

How to restore the factory settings of HP computer

Pointer concept & character pointer & pointer array yyds dry inventory

Esp-idf turns off serial port log output.

How to quickly build high availability of service discovery
随机推荐
SDMU OJ#P19. Stock trading
Flutter internationalized Intl
Comparable interface and comparator interface
X Opencv feature point detection and matching
[untitled]
Fluent learning (5) GridView
What are the common computer problems and solutions
Format cluster and start cluster
Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
Yyds dry goods inventory Spring Festival "make" your own fireworks
Take you to master the formatter of visual studio code
ThreadLocal function, scene and principle
Buuctf, web:[geek challenge 2019] buyflag
How to restore the factory settings of HP computer
LeetCode 540. A single element in an ordered array
Buuctf, misc: sniffed traffic
In VS_ In 2019, scanf and other functions are used to prompt the error of unsafe functions
FPGA tutorial and Allegro tutorial - link
The difference between single power amplifier and dual power amplifier
Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet