简体   繁体   English

如何使英雄小部件在路线转换中飞到其他小部件下方

[英]How to make hero widget fly below other widget in route transition

How to make hero widget fly below appBar and bottomBar widgets in route transition.如何让 hero 小部件在路由转换中飞到appBarbottomBar小部件下方。 I had tried to warp other widgets with hero also but no luck.我也曾尝试用 hero 扭曲其他小部件,但没有运气。

During a transition, Flutter places the Hero's in the order they are found in the widget (element) tree;在过渡期间,Flutter 按照在小部件(元素)树中找到的顺序放置英雄; last one on top.最后一个在上面。 So you might be able to organise your screen in such a way that, the app bar and bottom bar heros are found later in the tree than the body containing other heros.因此,您可能能够以这样一种方式组织您的屏幕,即在树中找到应用栏和底部栏英雄的时间要晚于包含其他英雄的主体。 For example with a Stack :例如使用Stack

Stack(
  children: [
    Body(),
    Positioned(
      top: 0,
      left: 0,
      right: 0,
      child: AppBar(),
    ),
    Positioned(
      bottom: 0,
      left: 0,
      right: 0,
      child: BottomBar(),
    ),
  ],
)

This relies on the implementation details of Flutter's heros, so it is rather hacky.这依赖于 Flutter 的 heros 的实现细节,所以比较 hacky。

Another approach would be to copy Flutter's HeroController, Hero and related code and modify it to order the Hero OverlayEntries by a new "z-index" property of the Hero widget.另一种方法是复制 Flutter 的 HeroController、Hero 和相关代码并对其进行修改,以通过 Hero 小部件的新“z-index”属性对 Hero OverlayEntries 进行排序。

The Heros "fly" in the Navigator's Overlay.英雄在导航器的叠加层中“飞”。 So yet another approach could be to place your app bar and bottom bar on top of the Navigator (for example with a Stack like above).因此,另一种方法可能是将您的应用栏和底部栏放在导航器的顶部(例如使用上面的堆栈)。

None of these are great of course.当然,这些都不是很好。

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

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