Open MominRaza opened 1 year ago
This message is from Flutter's deafult ListView.builder
ListView.builder
It is legal for itemBuilder to return null. If it does, the scroll view will stop calling itemBuilder, even if it has yet to reach itemCount.
Do same in MasonryGridView.extent and in other widgets if possible.
MasonryGridView.extent
Use case: It comes handy in infinite scrolling where we don't know page length.
ListView.builder( itemBuilder: (context, index) { final page = index ~/ 10 + 1; return ref.watch(postsProvider(page)).when( data: (posts) { if (posts.length <= index) return null; //here i'm returning null, this is not possible with MasonryGridView.extent return PostItem(post: posts[index]); }, error: (_, __) => const SizedBox(), loading: () => const PostItemSkeleton(), ); }, ),
This message is from Flutter's deafult
ListView.builder
Do same in
MasonryGridView.extent
and in other widgets if possible.Use case: It comes handy in infinite scrolling where we don't know page length.