home_page.dart
2.92 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import 'package:Parlando/poem/components/video_slides.dart';
import 'package:flutter/material.dart';
class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
@override
HomeState createState() => HomeState();
}
class HomeState extends State<Home> {
final PageController _controller = PageController();
@override
void initState() {
super.initState();
//设置pageView 滑动监听
_controller.addListener(() {
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
print('滑动到了最底部');
_getMore();
}
});
}
/// 下拉刷新方法,为list重新赋值
Future<void> _onRefresh() async {
await Future.delayed(const Duration(seconds: 1), () {
print('refresh');
setState(() {});
});
}
/// 上拉加载更多
Future<void> _getMore() async {
await Future.delayed(const Duration(seconds: 1), () {
print('_getMore');
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
RefreshIndicator(
//下拉刷新触发方法
onRefresh: _onRefresh,
//设置listView
child: PageView(
controller: _controller,
//设置滑动方向
scrollDirection: Axis.vertical,
children: const [
VideoSlides(),
VideoSlides(),
VideoSlides(),
],
),
),
Positioned(
top: 18.0,
left: 10.0,
right: 10.0,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () {},
child: const Text(
"临境",
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
),
const Text(
"|",
style: TextStyle(color: Colors.white),
),
TextButton(
onPressed: () {},
child: const Text(
"妙众",
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
),
const Text(
"|",
style: TextStyle(color: Colors.white),
),
TextButton(
onPressed: () => {},
child: const Text(
"新鲜",
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
),
],
),
),
),
],
);
}
}