首页 > 解决方案 > 导航到 Fluttter 中的新小部件时如何不处理以前的小部件?

问题描述

我目前在做什么

Navigator.push(context,
            RouteAnimationFadeIn(NewWidget(someValue), true));

路线动画淡入:

class RouteAnimationFadeIn extends PageRouteBuilder {
final Widget widget;
final bool shouldMaintainState;

RouteAnimationFadeIn(this.widget, this.shouldMaintainState)
  : super(pageBuilder: (BuildContext context, Animation<double> animation,
        Animation<double> secondaryAnimation) {
      return widget;
    }, transitionsBuilder: (BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        Widget child) {
      return FadeTransition(
        opacity: animation,
        child: child,
      );
    });

@override
bool get maintainState {
  return shouldMaintainState;
}
}

这将处理前一个小部件,从而处理其中所有表单字段的数据。我想要的是一个片段添加类似 Android 的功能,以便新的小部件在旧小部件的水龙头上打开,这样,当我使用时,我可以Navigator.pop(context);看到其中的旧数据。

我试过这个,但它不起作用。

标签: flutterdart

解决方案


推荐阅读