gpt4 book ai didi

在底部导航栏上推送新屏幕时出现 Flutter Transition 动画问题

转载 作者:行者123 更新时间:2023-12-02 16:42:24 27 4
gpt4 key购买 nike

我有一个 MaterialApp,其中有一个 IndexedStack 作为主页,用于 BottomBarNavigation。现在,在其中一个“选项卡”中,我希望像在 iOS 中那样完成页面转换。

部分技巧可以使用 Navigator.push 中的 CupertinoPageRoute 完成,如下所示:

Navigator.of(context, rootNavigator: true).push(CupertinoPageRoute<bool>(
//fullscreenDialog: true,
builder: (BuildContext context) => new DescriptionPage(),

));

这导致新页面作为 iOS 应用程序从右侧滑动。但是,我还希望第一页以视差向右移动,正如 CupertinoPageRoute 的文档中所说:

The page also shifts to the left in parallax when another page enters to cover it.

如果第一页本身是通过“Navigator.push(CupertinoPageRoute ...”创建的,这将完成,但正如我提到的,我的第一页是应用程序主页的主要页面之一。

当前的过渡样式: the new page slides in from right, but the current page does not shift to left

如您所见,当前页面并没有向左移动。可能有一种方法可以使当前页面的小部件充当由 CupertinoPageRoute 构建的小部件,以便当前页面本身在新页面进入时向左滑动。

最佳答案

在 MaterialApp 的 theme: 参数中,试试这个:

MaterialApp(
theme: ThemeData( //or replace with your custom ThemeData.copywith()
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder()
}
),
),
)

关于在底部导航栏上推送新屏幕时出现 Flutter Transition 动画问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61349628/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com