Created
August 23, 2018 11:18
-
-
Save QuirijnGB/ba1fbe6e5998690071935436ed996ead to your computer and use it in GitHub Desktop.
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
| 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