I have screen contain Custom scroll view and inside it there some sliver and grid view inside sliver fill remaining I won't scrolling from the big list (not grid view) so I set the physics of grid view to Never Scrollable Scroll Physics and has Scroll Body to false
but I got this error
I tried thousands of solution on the internet but no thing change
please help
this is the code
class SearchViewBody extends StatelessWidget {
const SearchViewBody({super.key, this.searchText = ""});
final String searchText;
@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: SearchViewAppBar(),
),
SliverToBoxAdapter(
child: SearchViewWhiteBox(searchText: searchText),
),
SliverFillRemaining(
hasScrollBody: false,
fillOverscroll: true,
child: BlocBuilder<SearchCubit,SearchState>(
builder: (context,state){
if(state is SearchLoading) {
return Container(color: Colors.white,child: LoadingWidget());
} else if(state is SearchSuccess){
if(state.products.isEmpty){
return Column(children: [Expanded(child: Container(color: Colors.white,child: Center(child: Text("no not found")))),],);
}else
return Container(color: Colors.white,child: SearchItemsList(state: state,));
}
else if(state is SearchFailure)
return Center(child: Text(state.message));
else
return Container();
}
)
)
],
);
}
}
and the grid view widget
class SearchItemsList extends StatelessWidget {
const SearchItemsList({super.key,this.state});
final SearchSuccess? state;
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
width: double.infinity,
child: GridView.builder(
padding: EdgeInsets.symmetric(horizontal: 20),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 0.7,
crossAxisSpacing: 10,
mainAxisSpacing: 10
),
itemCount: state!.products.length,
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return SearchProductItem(product: state!.products[index]);
}
),
);
}
}
the exception I get
The following assertion was thrown during performLayout():
RenderShrinkWrappingViewport does not support returning intrinsic dimensions.
Calculating the intrinsic dimensions would require instantiating every child of the viewport, which defeats the point of viewports being lazy.
If you are merely trying to shrink-wrap the viewport in the main axis direction, you should be able to achieve that effect by just giving the viewport loose constraints, without needing to measure its intrinsic dimensions.