I am encountring a overflow problem within SLiverlist. I have SliverAppBar that callapsed when scrolling the SliverList but at a moment I encounter the RenderFlex overflow by 337 pixels on bottom.
Here is the code:
class MainScreen extends StatelessWidget {
const MainScreen({super.key});
@override
Widget build(BuildContext context) {
return SafeArea(
child: DefaultTabController(
length: 9,
child: Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
backgroundColor: AppColors.topBackgroundDarkColor,
expandedHeight: 200.h, // Height when expanded
floating: true,
pinned: true,
flexibleSpace: const MainAppbar(),
collapsedHeight: 50.h,
toolbarHeight: 50.h,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
if (index == 0) {
return SizedBox(
height: MediaQuery.of(context).size.height + 200,
child: TabBarView(
children: Constants.screens.map((screen) {
return ListTile(
title: screen,
);
}).toList(),
),
);
}
},
),
),
],
),
),
),
);
}
}
What I have tried?
First: if I adjust the height of the SizedBox to (+ 337 height) pixel. it solves the issue.
Like this:
height: MediaQuery.of(context).size.height + 200 + 337,
But What if it is more than that?? How can I know the needed height?
I couldn't get the height of the widget because of it still building..
I tried more solutions like: Expanded(), Flexable().. but no effect..
I tried also to wrap that with SingleChildScrollView(), it scrolls now but I lost the callapsing of the SliverAppBar..
Please can someone help?
