繁体   English   中英

Get.to(MyPage()) - 如何删除所有以前的路由 - Flutter GetX

[英]Get.to(MyPage()) - How to remove all previous routes - Flutter GetX

我有一个简单的 Flutter 应用程序,我想删除所有以前的路由,但我想使用 GetX,该怎么做?

现在它与

Navigator.of(context).pushNamedAndRemoveUntil('/home', (Route<dynamic> route) => false);

但我想知道Get.to或类似的正确方法

如果您想删除最后一页,请使用它。

Get.off(Home());

如果您想删除所有以前的页面,请使用它。

Get.offAll(Home());

很简单

Get.offAll(Home());

与命名路由:

Get.offAllNamed('/home');

有关文档的更多信息: https : //github.com/jonataslaw/getx/blob/master/documentation/en_US/route_management.md

使用Get.reset()这将删除所有以前的路由

您正在寻找Get.reset(); . 请检查此页面

 /// Clears all registered instances (and/or tags).
 /// Even the persistent ones.
 ///
 /// - [clearFactory] clears the callbacks registered by [Get.lazyPut()]
 /// - [clearRouteBindings] clears Instances associated with Routes when using
 ///   [GetMaterialApp].
 bool reset({bool clearFactory = true, bool clearRouteBindings = true}) =>
  GetInstance().reset(
      clearFactory: clearFactory, clearRouteBindings: clearRouteBindings);

尝试这个:

 Get.offNamedUntil('home', (route) => false);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM