-
-
Notifications
You must be signed in to change notification settings - Fork 635
/
ball_pulse.dart
62 lines (58 loc) · 1.52 KB
/
ball_pulse.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
import 'dart:async';
import 'package:example/widget/sample_list_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_easyrefresh/ball_pulse_header.dart';
import 'package:flutter_easyrefresh/ball_pulse_footer.dart';
/// 球脉冲样式
class BallPulsePage extends StatefulWidget {
@override
BallPulsePageState createState() {
return BallPulsePageState();
}
}
class BallPulsePageState extends State<BallPulsePage> {
// 总数
int _count = 20;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('BallPulse'),
backgroundColor: Colors.white,
),
body: EasyRefresh.custom(
header: BallPulseHeader(),
footer: BallPulseFooter(),
onRefresh: () async {
await Future.delayed(Duration(seconds: 2), () {
if (mounted) {
setState(() {
_count = 20;
});
}
});
},
onLoad: () async {
await Future.delayed(Duration(seconds: 2), () {
if (mounted) {
setState(() {
_count += 20;
});
}
});
},
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return SampleListItem();
},
childCount: _count,
),
),
],
),
);
}
}