navigation - Flutter:Navigator.pushReplacement/pushAndRemoveUntil 终止动画

标签 navigation dart flutter

我想知道是否有一种方法可以使用导航器调用,不允许用户向后导航并保持 Hero Widget 的动画完好无损?我在启动画面和登录屏幕之间有一个英雄小部件图像转换,但我想阻止用户从启动画面返回。 Navigator.pushAndRemoveUntil 和 Navigator.pushReplacement 都是终止动画过渡动画。

最佳答案

我的解决方案,主要是因为 WillPopScope 污染了另一个页面并阻止了 Android 上应该关闭应用程序的硬件按钮:

  Future<void> pushAndReplace(String routeName) async {
    final current = ModalRoute.of(context);
    Navigator.pushNamed(context, '/login');
    await Future.delayed(Duration(milliseconds: 1));
    Navigator.removeRoute(context, current);
  }

关于navigation - Flutter:Navigator.pushReplacement/pushAndRemoveUntil 终止动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49786736/

相关文章:

html - Wordpress 导航子/父

dart - setState 不在 Dart/Flutter 中重新加载状态?

dictionary - Dart中的Map []运算符在哪里定义?

SwiftUI 2 : the way to open view in new window

listview - 导航后将滚动 Controller 动画化到 ListView.builder 的顶部

css - Joomla 一页站点的滚动指示器

android - Firebase Phone Auth (Flutter) 在某些 iOS 设备上不工作

dart - 如何在 Dart/Flutter 中从它自己的回调 (onPressed) 中访问 Widget

android-studio - 如何在 Flutter 中运行不同的 dart 文件?

dart - Flutter VideoPlayerController "setState() or markNeedsBuild() called during build."