-
-
Notifications
You must be signed in to change notification settings - Fork 641
/
empty.dart
87 lines (83 loc) · 2.34 KB
/
empty.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
81
82
83
84
85
86
87
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:example/generated/i18n.dart';
/// 空视图示例
class EmptyPage extends StatefulWidget {
@override
EmptyPageState createState() {
return EmptyPageState();
}
}
class EmptyPageState extends State<EmptyPage> {
// 总数
int _count = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(S.of(context).emptyWidget),
backgroundColor: Colors.white,
),
body: EasyRefresh.custom(
emptyWidget: _count == 0
? Container(
height: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: SizedBox(),
flex: 2,
),
SizedBox(
width: 100.0,
height: 100.0,
child: Image.asset('assets/image/nodata.png'),
),
Text(
S.of(context).noData,
style: TextStyle(fontSize: 16.0, color: Colors.grey[400]),
),
Expanded(
child: SizedBox(),
flex: 3,
),
],
),
)
: null,
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return SampleListItem();
},
childCount: _count,
),
),
],
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;
});
}
});
},
),
);
}
}