Fix pop may call multiple times

This commit is contained in:
2024-06-02 14:03:33 +00:00
committed by GitHub
parent ca8fb15f0e
commit 727d3ecbe3
4 changed files with 7 additions and 1 deletions

View File

@@ -115,6 +115,7 @@ class _NewDownloadTaskPage extends State<NewDownloadTaskPage> {
WidgetsBinding.instance!.addPostFrameCallback((_) {
context.canPop() ? context.pop() : context.go("/task_manager");
});
_ok = false;
}
if (!_fetched) fetchDefaultCfg();
final i18n = AppLocalizations.of(context)!;

View File

@@ -99,6 +99,7 @@ class _NewExportZipTaskPage extends State<NewExportZipTaskPage> {
WidgetsBinding.instance!.addPostFrameCallback((_) {
context.canPop() ? context.pop() : context.go("/task_manager");
});
_ok = false;
}
if (!_fetched) fetchDefaultCfg();
final i18n = AppLocalizations.of(context)!;

View File

@@ -87,6 +87,7 @@ class _NewUserPage extends State<NewUserPage> {
SchedulerBinding.instance.addPostFrameCallback((_) {
context.canPop() ? context.pop() : context.go("/users");
});
_newUserId = null;
return Container();
}
final i18n = AppLocalizations.of(context)!;

View File

@@ -45,6 +45,7 @@ class _LoginPageState extends State<LoginPage>
bool _isValid = false;
bool _isLogin = false;
bool _checkAuth = false;
bool _tryPoped = false;
void _onStateChanged(dynamic _) {
setState(() {});
@@ -120,10 +121,12 @@ class _LoginPageState extends State<LoginPage>
Widget build(BuildContext context) {
tryInitApi(context);
_checkStatus(context);
if (isTop(context) && auth.user != null) {
if (isTop(context) && auth.user != null && !_tryPoped) {
SchedulerBinding.instance.addPostFrameCallback((_) {
context.canPop() ? context.pop() : context.go("/");
});
_tryPoped = true;
return Container();
}
return Scaffold(
appBar: AppBar(