Why is sliverlist not working in my customscrollview?
915
Remove the
const
keyword of theCustomScrollView
.Replace
SliverChildBuilderDelegate((context) {})
with:
SliverChildBuilderDelegate((context, index) {})
Full code:
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('Sample Slivers'),
leading: Icon(Icons.menu),
backgroundColor: Colors.orangeAccent,
expandedHeight: 90.0,
floating: true,
pinned: true,
snap: false,
),
SliverList(
delegate: SliverChildBuilderDelegate((context, index) {}),
)
],
),
bottomNavigationBar: _navigatorAppBar(),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: _buildFab(),
);
}
Author by
Deyvi Tabora
Updated on December 23, 2022Comments
-
Deyvi Tabora over 1 year
I am trying to add a sliverlist but it does not work for me, I am very new to using flutter and I am confused.
@override Widget build(BuildContext context) { return Scaffold( body: const CustomScrollView( slivers: <Widget>[ SliverAppBar( title: Text('Sample Slivers'), leading: Icon(Icons.menu), backgroundColor: Colors.orangeAccent, expandedHeight: 90.0, floating: true, pinned: true, snap: false, ), SliverList( delegate: SliverChildBuilderDelegate((context) {}), ) ], ), bottomNavigationBar: _navigatorAppBar(), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: _buildFab(), ); } }