Home > database >  How can I use "InViewNotifierList"?
How can I use "InViewNotifierList"?

Time:07-19

InViewNotifierList(
   isInViewPortCondition:
  (double deltaTop, double deltaBottom, double viewPortDimension) {
   return deltaTop < (0.5 * viewPortDimension) &&
    deltaBottom > (0.5 * viewPortDimension);
 },
    itemCount: 10,
    builder: (BuildContext context, int index) {
      return InViewNotifierWidget(
      id: '$index',
      builder: (BuildContext context, bool isInView, Widget child) {
        return Container(
          height: 250.0,
          color: isInView ? Colors.green : Colors.red,
          child: Text(
            isInView ? 'Is in view' : 'Not in view',
          ),
        );
      },
    );
   }
 ),

I get this error message:The argument type 'Container Function(BuildContext, bool, Widget)' can't be assigned to the parameter type 'Widget Function(BuildContext, bool, Widget?)'.

CodePudding user response:

Widget Function(BuildContext, T, Widget) cannot accept a null value for the widget, which is required by the Widget Function(BuildContext, T, Widget?) signature.Adding ? after Widget will resolve this error.

enter image description here

  • Related