Skip to content

Instantly share code, notes, and snippets.

@Piinks
Created January 23, 2020 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Piinks/b062b0587477b6f9931574fbe14cbeba to your computer and use it in GitHub Desktop.
Save Piinks/b062b0587477b6f9931574fbe14cbeba to your computer and use it in GitHub Desktop.
Nested Lists
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