[英]flutter navigation pop to different screen
i use我用
Navigator.push(context, MaterialPageRoute(builder: (context) => B()));
to push from A to B to C to D i need to pop back from D to B i also need to remove D and C form stack i used从 A 推到 B 到 C 到 D 我需要从 D 弹回 B 我还需要从我使用的堆栈中删除 D 和 C
Navigator.popUntil(context, (route) => route is B);
but it gives me a blank screen it works only with initial route, sloutions i found is to use但它给了我一个空白屏幕,它只适用于初始路线,我发现的 sloutions 是使用
Navigator.pop();
twice两次
is there any alternative solutions?有没有其他解决方案?
You can set route name.您可以设置路线名称。
Navigator.push(
context,
MaterialPageRoute(
settings: RouteSettings(name: '/B'),
builder: (context) => B(),
),
);
When you call popUntil
set parameter using this name.当您使用此名称调用
popUntil
设置参数时。
Navigator.popUntil(
context,
ModalRoute.withName('/B'),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.