Ai
1 Star 4 Fork 4

lzh/FlutterStudy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
GuidePage.dart 3.73 KB
一键复制 编辑 原始数据 按行查看 历史
lzh 提交于 2021-08-14 22:22 +08:00 . sharepreference、优化
import 'package:dots_indicator/dots_indicator.dart';
import 'package:flutter/material.dart';
import 'package:flutter_study/MainPage.dart';
class GuidePage extends StatefulWidget {
@override
_GuidePageState createState() => _GuidePageState();
}
class _GuidePageState extends State<GuidePage> {
var _index = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
alignment: Alignment.bottomCenter,
children: [
PageView(
scrollDirection: Axis.horizontal,
reverse: false,
onPageChanged: (index) {
setState(() {
_index = index;
});
},
controller: PageController(
initialPage: 0, keepPage: false, viewportFraction: 1),
pageSnapping: true,
physics: ClampingScrollPhysics(),
children: [
Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/image_guide_2.jpg"),
fit: BoxFit.fill)),
),
Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/image_guide_1.jpg"),
fit: BoxFit.fill)),
),
Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/image_guide_3.jpg"),
fit: BoxFit.fill)),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Positioned(
bottom: 100,
child: ElevatedButton(
onPressed: () {
Navigator.pushAndRemoveUntil(context,
new MaterialPageRoute(
builder: (BuildContext context) {
return MainPage();
}), (route) => route == null);
},
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Colors.white),
foregroundColor:
MaterialStateProperty.all(Colors.black),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10))),
side: MaterialStateProperty.all(
BorderSide(color: Colors.white))),
child: Text("开启Flutter学习之旅")))
],
),
)
],
),
Positioned(
bottom: 70,
child: DotsIndicator(
mainAxisAlignment: MainAxisAlignment.center,
reversed: false,
dotsCount: 3,
position: _index.toDouble(),
decorator: DotsDecorator(
color: Colors.black87, // Inactive color
activeColor: Colors.redAccent,
)))
],
),
);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fjjxxy/flutter-study.git
git@gitee.com:fjjxxy/flutter-study.git
fjjxxy
flutter-study
FlutterStudy
master

搜索帮助