代码拉取完成,页面将自动刷新
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,
)))
],
),
);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。