Created
January 23, 2020 22:29
-
-
Save Piinks/b062b0587477b6f9931574fbe14cbeba to your computer and use it in GitHub Desktop.
Nested Lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
body: NestedScrollView( | |
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { | |
// These are the slivers that show up in the "outer" scroll view. | |
return <Widget>[ | |
SliverAppBar(title: Text('Demo!')), | |
SliverFixedExtentList( | |
itemExtent: 48.0, | |
delegate:SliverChildBuilderDelegate( | |
(BuildContext context, int index) => ListTile(title: Text('Outer Item $index')), | |
childCount: 20, | |
), | |
), | |
]; | |
}, | |
// These are the boxes that show up in the "inner" scroll view. | |
body: ListView.builder( | |
padding: const EdgeInsets.all(8), | |
itemCount: 20, | |
itemBuilder: (BuildContext context, int index) => Container( | |
color: Colors.cyan, | |
height: 50, | |
child: Center(child: Text('Inner Item $index')), | |
), | |
), | |
), | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment