Skip to content

Instantly share code, notes, and snippets.

@QuirijnGB
Created August 23, 2018 11:18
Show Gist options
  • Select an option

  • Save QuirijnGB/ba1fbe6e5998690071935436ed996ead to your computer and use it in GitHub Desktop.

Select an option

Save QuirijnGB/ba1fbe6e5998690071935436ed996ead to your computer and use it in GitHub Desktop.
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<int> data = [];
int currentLength = 0;
final int increment = 10;
@override
void initState() {
_loadMore();
super.initState();
}
void _loadMore() {
setState(() {
for (var i = currentLength; i <= currentLength + increment; i++) {
data.add(i);
}
currentLength = data.length;
});
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: LazyLoadScrollView(
onEndOfPage: () => _loadMore(),
child: ListView.builder(
itemCount: data.length,
itemBuilder: (context, position) {
return new DemoItem(position);
},
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment