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

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

问题描述

如何将一个小部件推送到另一个小部件的框架中?例如,我有一个带有 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?

推荐答案

你可以使用 Navigator 小部件可在您的应用中提供任意数量的单独导航器.每个导航器都将维护它自己的导航堆栈.例如,如果你想垂直分割你的应用程序,每一半都有自己的导航堆栈:

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天全站免登陆