/
shimmer_indicator.dart
80 lines (75 loc) · 1.95 KB
/
shimmer_indicator.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Author: Jpeng
* Email: peng8350@gmail.com
* Time: 2019-07-08 11:05
*/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../other/shimmer_indicator.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class ShimmerIndicatorExample extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _ShimmerIndicatorExampleState();
}
}
/*
@required Color baseColor,
@required Color highlightColor,
this.period = const Duration(milliseconds: 1500),
this.direction = ShimmerDirection.ltr,
*/
class _ShimmerIndicatorExampleState extends State<ShimmerIndicatorExample> {
RefreshController _refreshController = RefreshController();
List<String> data = [
"1",
"2",
"1",
"2",
"1",
"2",
"1",
"2",
"1",
"2",
"1",
"2"
];
@override
Widget build(BuildContext context) {
// TODO: implement build
return SmartRefresher(
header: ShimmerHeader(
text: Text(
"PullToRefresh",
style: TextStyle(color: Colors.grey, fontSize: 22),
),
),
footer: ShimmerFooter(
text: Text(
"PullToRefresh",
style: TextStyle(color: Colors.grey, fontSize: 22),
),
),
controller: _refreshController,
enablePullUp: true,
child: ListView.builder(
itemCount: data.length,
itemExtent: 100.0,
itemBuilder: (c, i) => Card(),
),
onRefresh: () async {
await Future.delayed(Duration(milliseconds: 2000));
_refreshController.refreshCompleted();
},
onLoading: () async {
await Future.delayed(Duration(milliseconds: 2000));
for (int i = 0; i < 10; i++) {
data.add("1");
}
setState(() {});
_refreshController.loadComplete();
});
}
}