-
Notifications
You must be signed in to change notification settings - Fork 1
/
infiniteScroll.Dart
50 lines (44 loc) · 1.19 KB
/
infiniteScroll.Dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_ChatServerDividedState createState() => new _ChatServerDividedState();
}
class _ChatServerDividedState extends State<MyApp> {
final List<String> items = List<String>.generate(10, (i) => "Item $i");
@override
Widget build(BuildContext context) {
final title = 'Long List';
return MaterialApp(
title: title,
home: Scaffold(
appBar: AppBar(
title: Text(title),
),
body: ListView.builder(
//itemCount: items.length,
itemBuilder: (context, index) {
if(index< items.length){
return ListTile(
title: Text('${items[index]}'),
);
}else{
myTypedFuture();
return Center(child:CircularProgressIndicator());
}
},
itemCount: items.length + 1,
),
),
);
}
Future myTypedFuture() async {
await Future.delayed(Duration(seconds: 3));
setState((){
final List<String> items2 = List<String>.generate(10, (i) => "Item $i");
items.addAll(items2);
});
}
}