How to detect if a widget is visible or not in Flutter

37 Views Asked by At

I have the following widget structure:

Stack
  ...Widget1 (static resource with image and text)
  ...Widget2 (Flutter webview whose content can be transparent sometimes at runtime for unknown reasons)

There are 2 possible cases here:

  1. Widget2's content is fully rendered and covers the Widget1 content fully -> Widget1 is not visible
  2. Widget2's content is not rendered and does not cover the Widget1 content at all -> Widget1 is visible through Widget2, because it's content is transparent

Is it possible to detect if a Widget1's content is visible or not (covered or not by Widget2's content) at runtime?

I have tried using https://pub.dev/packages/visibility_detector plugin for this, however it is not giving me the expected results. For exmaple, when Widget1's content is fully covered by Widget2's content, it shows that Widget1 is visible, because it is present in the widget tree srtucture, which is not what I am looking for. Only when app is in backgoround or when the screen is not currently in viewport, it gives expected results, that Widget1's content is not visible.

Any ideas on how to solve this? Thanks.

0

There are 0 best solutions below