OnScrollBuilder constructor

OnScrollBuilder({
  1. Key? key,
  2. required InjectedScrolling listenTo,
  3. required Widget builder(
    1. InjectedScrolling
    ),
})

Listen to an InjectedScrolling state.

The builder method is invoked when scrolling start, while scrolling and when scrolling ends.

 OnScrollBuilder(
   listenTo: scroll,
   builder: (scroll) {
     if (scroll.hasReachedMinExtent) {
       return Text('isTop');
     }

     if (scroll.hasReachedMaxExtent) {
       return Text('isBottom');
     }

     if (scroll.hasStartedScrollingReverse) {
       return Text('hasStartedUp');
     }
     if (scroll.hasStartedScrollingForward) {
       return Text('hasStartedDown');
     }

     if (scroll.hasStartedScrolling) {
       return Text('hasStarted');
     }

     if (scroll.isScrollingReverse) {
       return Text('isScrollingUp');
     }
     if (scroll.isScrollingForward) {
       return Text('isScrollingDown');
     }

     if (scroll.isScrolling) {
       return Text('isScrolling');
     }

     if (scroll.hasEndedScrolling) {
       return Text('hasEnded');
     }
     return Text('NAN');
   },
 ),

Implementation

OnScrollBuilder({
  Key? key,
  required this.listenTo,
  required Widget Function(InjectedScrolling) builder,
}) : super(
          key: key,
          observers: (_) => [listenTo as ReactiveModelImp],
          builder: (_, __, ___) => builder(listenTo));