-
-
Notifications
You must be signed in to change notification settings - Fork 635
/
material.dart
62 lines (58 loc) · 1.52 KB
/
material.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/material_header.dart';
import 'package:flutter_easyrefresh/material_footer.dart';
/// 质感设计样式
class MaterialStylePage extends StatefulWidget {
@override
MaterialPageState createState() {
return MaterialPageState();
}
}
class MaterialPageState extends State<MaterialStylePage> {
// 总数
int _count = 20;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Material'),
backgroundColor: Colors.white,
),
body: EasyRefresh.custom(
header: MaterialHeader(),
footer: MaterialFooter(),
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,
),
),
],
),
);
}
}