I need to load data from BlocBuilder to a SliverGrid to show a grid of items.
When I use BlocBuilder as SliverGrid's delegate, I get this error:
The argument type 'BlocBuilder<dynamic, dynamic>' can't be assigned to the parameter type 'SliverChildDelegate'
What can I do?
This is a sample of my code:
SliverGrid(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
),
delegate: BlocBuilder<SubjectBloc, SubjectState>(
builder: (context, state) {
return SliverChildBuilderDelegate(
(
BuildContext context,
int index,
) {
return Text('$index');
},
);
},
),
),