'pushReplacementNamed or pushNamedAndRemoveUntil leads to an untappable page (WEB)

In the logout flow, I use pushNamedAndRemoveUntil (I tried pushReplacementNamed too) to lead the user to the login page.

The flow and animation runs correctly, but the LoginPage widget becomes untappable, you cannot interact with it in any way, there is something like a black, slightly opaque, fullscreen container that is on top of the page itself.

Logout flow

_showLogoutDialog(BuildContext context) => showDialog(
      context: context,
      builder: (BuildContext context) => StatefulBuilder(
            builder: (context, setState) => BackdropFilter(
              filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
              child: AlertDialog(
                shape: const RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(15))),
                title: Text(IridiMgmtLocalizations.of(context)!.exitApp),
                content:
                    Text(IridiMgmtLocalizations.of(context)!.confirmExitApp),
                actions: <Widget>[
                  FlatButton(
                    child: Text(IridiMgmtLocalizations.of(context)!.abort),
                    onPressed: () {
                      Navigator.pop(context);
                    },
                  ),
                  FlatButton(
                    child: const Text("Ok"),
                    onPressed: () {
                      setState(() => _isLoggingOut = true);
                      Future.delayed(
                          Duration.zero, () => _buildShowDialog(context));
                      if (!kIsWeb) {
                        FirebaseServiceUtils()
                            .unsubscribeFromTopics(widget.eatMenu.linkId)
                            .then((_) {
                          print(
                              'Unsubscribed from ${widget.eatMenu.linkId} topics!');
                          widget.keyValueStore.store
                              .setBool("autoAccesso", false);

                          setState(() => _isLoggingOut = false);
                          if (widget.keyValueStore.getSessionRole() ==
                              'SUPER_ADMIN') {
                            String? superAdminLinkId =
                                LoginUtils.getInstance()!.getSuperAdminLinkId();
                            EatMenu superAdminMenu = EatMenu.fromJson(
                                json.decode(widget.keyValueStore.store
                                    .getString('eatMenu_$superAdminLinkId')!));
                            Navigator.of(context).pushNamedAndRemoveUntil(
                                AppRoutes.home, (r) => false,
                                arguments: superAdminMenu);
                          } else {
                            Navigator.of(context)
                                .pushReplacementNamed(AppRoutes.login);
                          }
                        });
                      } else {
                        widget.keyValueStore.store
                            .setBool("autoAccesso", false);
                        setState(() => _isLoggingOut = false);
                        if (widget.keyValueStore.getSessionRole() ==
                            'SUPER_ADMIN') {
                          Navigator.of(context).pushNamedAndRemoveUntil(
                              AppRoutes.home, (r) => false);
                        } else {
                          Navigator.of(context).pushNamedAndRemoveUntil(
                              AppRoutes.login, (r) => false);
                        }
                      }
                    },
                  ),
                ],
              ),
            ),
          ));

Snippet of LoginPage class

@override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
        child: Scaffold(
            key: scaffoldKey,
            body: SingleChildScrollView(
              child: Align(
                  alignment: Alignment.center,
                  child: Padding(
                    padding: const EdgeInsets.only(top: 25),
                    child: Column(
                      children: [
                        _buildIridiLogo(),
                        _buildLogin(),
                        _buildButton(context)
                      ],
                    ),
                  )),
            )));
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source