1

I have a SingleChildScrollView that contains some widgets inside it. I want to listen if a widget becomes visible on the screen. is there any widget or sample code for this scenario?

reza
  • 1,354
  • 1
  • 7
  • 25
  • 1
    Try these answer [here](https://stackoverflow.com/questions/51069712/how-to-know-if-a-widget-is-visible-within-a-viewport) someone asked the same question. – Victor Ephraim Dec 29 '21 at 11:58

1 Answers1

0

One package might be helpful is VisibilityDetector. You should be able to wrap around your child widget like this and execute callbacks

VisibilityDetector(
key: Key('my-widget-key'),
onVisibilityChanged: (visibilityInfo) {
  var visiblePercentage = visibilityInfo.visibleFraction * 100;
  debugPrint(
      'Widget ${visibilityInfo.key} is ${visiblePercentage}% visible');
},
child: someOtherWidget,
);
Brian Wang
  • 20
  • 5