随着残疾的后背导航有效淡出

发布于 2025-02-03 19:34:22 字数 1461 浏览 0 评论 0原文

我想在禁用返回的可能性时从一个小部件过渡到另一个小部件(登录屏幕)。

禁用返回导航

a>解释了如何防止导航:

 Navigator.pushAndRemoveUntil(
                        context,
                        MaterialPageRoute(builder: (context) => AnyWidget()),
                            (Route<dynamic> route) => false,
                      );

找到了一个教程,在其中很好地解释了如何进行过渡:

class FadeRoute extends PageRouteBuilder {
  final Widget page;

  FadeRoute({required this.page})
      : super(
    pageBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        ) =>
    page,
    transitionDuration: Duration(seconds: 3 ),
    transitionsBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        Widget child,
        ) =>
        Container(color: Colors.white, child: FadeTransition(
          opacity: animation,
          child: child,
        )),
  );
}

并致电:

 Navigator.of(context).push(FadeRoute(page: AnyWidget()));

现在我的问题结合在一起

:我如何将pushandremoveuntilTransitionSbuilder ?

非常感谢!

I want to make a transition from one widget to another while disabling the possibility to come back (login screen).

Disabling back navigation

Here it is explained how to prevent navigation back:

 Navigator.pushAndRemoveUntil(
                        context,
                        MaterialPageRoute(builder: (context) => AnyWidget()),
                            (Route<dynamic> route) => false,
                      );

Found a tutorial where it is remarkably well explained how to make a transition:

class FadeRoute extends PageRouteBuilder {
  final Widget page;

  FadeRoute({required this.page})
      : super(
    pageBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        ) =>
    page,
    transitionDuration: Duration(seconds: 3 ),
    transitionsBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        Widget child,
        ) =>
        Container(color: Colors.white, child: FadeTransition(
          opacity: animation,
          child: child,
        )),
  );
}

And call:

 Navigator.of(context).push(FadeRoute(page: AnyWidget()));

Combining both

Now my question: How can I combine pushAndRemoveUntil with transitionsBuilder ?

Many thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文