屏幕的颤振导航 [英] Flutter navigation for part of screen

查看:45
本文介绍了屏幕的颤振导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将一个小部件推入另一个小部件的框架中?例如,我有一个包含2个容器的列,其中每个容器占据屏幕的一半.我想进行导航,例如仅在底部容器中.容器视图具有自己的UINavigationController时,与iOS中的逻辑相同.

How can I push a widget in the frame of another widget? For example I have a Column with 2 Containers where every Container takes half of the screen. I'd like to make a navigation e.g. only in the bottom container. The same logic as in iOS when the container view has it's own UINavigationController.

据我了解,MaterialPageRoute只能将小部件推到全屏状态,除抽象类外,没有其他Route类.也许我应该自己创建ModalRoute/TransitionRoute的子类?

As I understood MaterialPageRoute can push widgets only to fullscreen and there aren't any other Route classes, except abstract ones. Maybe I should make my own subclass of ModalRoute/TransitionRoute?

推荐答案

您可以使用

You can use the Navigator widget to provide any number of individual navigators in your app. Each Navigator will maintain it's own navigation stack. For example, if you wanted to split your app vertically with each half having it's own navigation stack:

Column(
  children: <Widget>[
    Navigator(...),
    Navigator(...)
  ]
)

如果执行此操作,则应考虑如何处理Android后退按钮(现在从技术上讲,您的应用程序中有3个导航器).默认情况下,它将仅侦听您的根导航器,因此您必须提供 WillPopScope 小部件层次结构中某个位置的小部件,以捕获后退按钮事件并从适当的导航器中弹出.

If you do this, you should consider how you want to handle the Android back button (now that you technically have 3 navigators in your app). By default, it will only listen to your root navigator so you will have to provide a WillPopScope widget somewhere in your widget hierarchy to capture back button events and pop from the appropriate navigator.

这篇关于屏幕的颤振导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆