PageView可以为你提供更为优雅的滑动,你可以指定scrollDirection为垂直还是水平,PageController可以监听滑动行为并且为该行为提供滑动动画.initialPage可以指定PageView的首页.

PageView
PageView
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
/*
@Author liwei
@Date 2019/1/11 5:07 PM
@Description: TODO
*/

import 'package:flutter/material.dart';

class GooglePageView extends StatefulWidget {
@override
GooglePageViewState createState() => new GooglePageViewState();
}

class GooglePageViewState extends State<GooglePageView> {
@override
Widget build(BuildContext context) {
PageController _controller = PageController(
initialPage: 1,
);
return PageView(
controller: _controller,
scrollDirection: Axis.horizontal,
children: <Widget>[
Container(
color: Colors.green,
),
PageView(
reverse: true,
scrollDirection: Axis.vertical,
controller: _controller,
children: <Widget>[
Container(
color: Colors.orange,
),
Container(
color: Colors.red,
),
Container(
color: Colors.blue,
),
],
),
Container(
color: Colors.lime,
),
],
);
}
}

代码github