build method Null safety

Widget? build(
  1. BuildContext context,
  2. int index
)

Returns the child with the given index.

Should return null if asked to build a widget with a greater index than exists. If this returns null, estimatedChildCount must subsequently return a precise non-null value (which is then used to implement RenderSliverBoxChildManager.childCount).

Subclasses typically override this function and wrap their children in AutomaticKeepAlive, IndexedSemantics, and RepaintBoundary widgets.

The values returned by this method are cached. To indicate that the widgets have changed, a new delegate must be provided, and the new delegate's shouldRebuild method must return true.

Implementation

Widget? build(BuildContext context, int index);