简体   繁体   English

脚手架后面的小部件

[英]widget behind Scaffold

I have a Widget behind the Scaffold that I made visible by setting Scaffold's backgroundColor to transparent. 我在Scaffold后面有一个Widget,通过将Scaffold的backgroundColor设置为透明,我可以看到它。

However, the Scaffold still absorbs the pointer event, but I want the background widget to consume the pointer event. 但是,Scaffold仍然会吸收指针事件,但我希望后台窗口小部件使用指针事件。

EDIT: 编辑:

I cannot put the widget in the Scaffold since it is a platform widget (map view) and I have to make sure it's the same instance across the whole app, otherwise funny things happen... also, page transitions should happen in front of the widget. 我不能把小部件放在Scaffold中,因为它是一个平台小部件(地图视图),我必须确保它在整个应用程序中是相同的实例,否则有趣的事情发生...而且,页面转换应该发生在前面小部件。

IgnorePointer(
  ignoring: true,
  child: Scaffold(
    ...
  ),
);

I solved the issues with two SingleChildRenderObjectWidgets. 我用两个SingleChildRenderObjectWidgets解决了这个问题。

One is called “Hole” and just a marker in the widget tree. 一个被称为“洞”,只是小部件树中的一个标记。 The other one is called “Sieve” and checks in its hitTest if a Hole was hit below it. 另一个被称为“Sieve”并检查其hitTest是否在其下方击中了一个洞。

If a Hole was hit, the hitTest is ignored. 如果击中了一个洞,则忽略hitTest。

Works perfectly! 完美的工作!

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

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