google / flutter.widgets

https://pub.dev/packages/flutter_widgets
BSD 3-Clause "New" or "Revised" License
1.37k stars 474 forks source link

VisibilityDetector fires event unexpectedly #510

Open satoyan opened 9 months ago

satoyan commented 9 months ago

Problem description

This is about VisibilityDetector. This widget fires 'onVisibilitychanged' event when any widget is on over its navigator route. every time virtual keyboard appears and disappears , VisibilityDetector under any widget's route will detect its visibiltychange and fires .

Steps to reproduce

  1. prepare a widget which has VisibilityDetector include any child widets.
  2. navigate to another widget which has html contents include text input form.
  3. tap text input form inside widget and show virtual keyboard
  4. VisibilityDetector fires onVisibilityChanged event .

Expected behavior

do not fire onVisibiliyChanged event

Actual behavior

fires onVisibilityChanged event

Environment

Flutter 3.16.2

both android , ios

thank you.

ttxz commented 8 months ago

Yes, I have this problem too, is there any solution?

astheras commented 4 days ago

same here. But as a temporary solution, i use smth like this

  void onVisibilityChanged(VisibilityInfo info) {
    // fires on keayboard appearance
    if (info.visibleFraction == 1 && needToReload) {
      needToReload= false;
      loadTimeZoneList();
      loadSelf();
    }

    if (info.visibleFraction == 0) {
      needToReload= true;
    }
  }