Im trying to create a draggable bottom sheet containing tab bars and tab views. While the sheet header tab bar buttons are being shown correctly, the tabviews are being shown with render issue(long red error)
I have no idea where exactly Im going wrong. I would be really glad if someone could help me in it.
DraggableScrollableSheet(
initialChildSize: 0.14,
minChildSize: 0.14,
snap: true,
maxChildSize: 1.0, // Adjust the max height as needed
builder: (BuildContext context, ScrollController scrollController) {
return Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 10.0,
),
],
),
child: CustomScrollView(
controller: scrollController,
slivers: [
const SliverToBoxAdapter(
child: Column(
children: [
SizedBox(
width: 50,
child: Divider(thickness: 4, color: Colors.black12),
),
Padding(
padding: EdgeInsets.only(left: 15.0, right: 15, top: 10),
child: SizedBox(width: double.infinity, child: Text("What's On, Dundee", style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold))),
),
],
),
),
SliverToBoxAdapter(
child: DefaultTabController(
length: 2,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Material(
child: TabBar(
labelColor: Colors.black,
indicatorColor: Colors.orangeAccent,
tabs: [
Tab(text: "Events"),
Tab(text: "Discounts"),
],
),
),
SliverFillRemaining(// ERROR POINTING HERE
child: TabBarView(
children: [
buildEventList(context, "Events"),
buildEventList(context, "Discounts"),
],
),
)
],
)
),
)
],
)
);
},
),
Widget buildEventList(BuildContext context, String eventType) {
List<Venue> venues = eventType == "Events"
? Provider.of<VenueProvider>(context).getTodaysEvents()
: Provider.of<VenueProvider>(context).getUpcomingEvents();
if (venues.isEmpty) {
return SliverToBoxAdapter(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(
height: 200,
child: OverflowBox(
minHeight: 200, maxHeight: 200, child: lot.Lottie.asset('assets/animations/EmptyAd.json'),
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Text(
"It looks quiet tonightnCheck back later to see What's on",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16, // Adjust font size as needed
),
),
),
],
),
);
}
return SliverList(
delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
Venue venue = venues[index];
return Column(
children: venue.advertisements.map((ad) {
return buildAdvertisementCard(context, venue, ad);
}).toList(),
);
},
),
);
}
error:
The following assertion was thrown building SliverFillRemaining(child: TabBarView, mode: [scrollable]):
A RenderFlex expected a child of type RenderBox but received a child of type RenderSliverFillRemainingWithScrollable.
RenderObjects expect specific types of children because they coordinate with their children during layout and paint. For example, a RenderSliver cannot be the child of a RenderBox because a RenderSliver does not understand the RenderBox layout protocol.
The RenderFlex that expected a RenderBox child was created by: Column ← _TabControllerScope ← DefaultTabController ← SliverToBoxAdapter ← Viewport ← IgnorePointer-[GlobalKey#64b2e] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#24366] ← Listener ← _ScrollableScope ← ⋯
The RenderSliverFillRemainingWithScrollable that did not match the expected child type was created by: _SliverFillRemainingWithScrollable ← SliverFillRemaining ← Column ← _TabControllerScope ← DefaultTabController ← SliverToBoxAdapter ← Viewport ← IgnorePointer-[GlobalKey#64b2e] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#24366] ← ⋯
The relevant error-causing widget was:
SliverFillRemaining SliverFillRemaining
I tried using expanded, flexible for the tab views but there was no progress and still caused the rendering issues.