gpt4 book ai didi

Flutter 自定义页面路由和 iOS 向后滑动手势

转载 作者:行者123 更新时间:2023-12-04 10:01:39 24 4
gpt4 key购买 nike

在我的应用程序中,我扩展了 MaterialPageRoute 以禁用页面过渡动画。

class NoAnimationMaterialPageRoute<T> extends MaterialPageRoute<T> {
NoAnimationMaterialPageRoute({
@required WidgetBuilder builder,
RouteSettings settings,
bool maintainState = true,
bool fullscreenDialog = false,
}) : super(
builder: builder,
maintainState: maintainState,
settings: settings,
fullscreenDialog: fullscreenDialog,
);

@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
return child;
}
}

这按预期工作,但是,它破坏了 iOS 向后滑动手势。如何重新启用它?我不关心任何动画,我只想刷卡回去工作。

最佳答案

如果你不需要任何动画,你可以这样做:

class NoAnimationMaterialPageRoute<T> extends MaterialPageRoute<T> {
NoAnimationMaterialPageRoute({
@required WidgetBuilder builder,
RouteSettings settings,
bool maintainState = true,
bool fullscreenDialog = false,
}) : super(
builder: builder,
maintainState: maintainState,
settings: settings,
fullscreenDialog: fullscreenDialog,
);

@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
var animation1 = Tween(begin: 1.0, end: 1.0).animate(animation);

final theme = Theme.of(context).pageTransitionsTheme;
return theme.buildTransitions<T>(
this,
context,
animation1,
secondaryAnimation,
child,
);
}
}
但是它只给了你向后滑动的功能,没有可见的效果,你想要手势的视觉效果,你需要制作你自己的 CupertinoPageTransition 版本

关于Flutter 自定义页面路由和 iOS 向后滑动手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61794806/

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