浏览代码

添加引导页

yanyi 3 年之前
父节点
当前提交
01921fb705
共有 7 个文件被更改,包括 14 次插入26 次删除
  1. 1 0
      android/app/src/main/AndroidManifest.xml
  2. 二进制
      assets/images/guide1.png
  3. 二进制
      assets/images/guide2.png
  4. 二进制
      assets/images/guide3.png
  5. 二进制
      assets/images/guide4.png
  6. 10 25
      lib/Screens/Guide/guide_screen.dart
  7. 3 1
      lib/main.dart

+ 1 - 0
android/app/src/main/AndroidManifest.xml

@@ -3,6 +3,7 @@
    <application
         android:label="flutter_demo"
         android:icon="@mipmap/ic_launcher">
+        <meta-data android:name="android.max_aspect" android:value="2.1" />
         <activity
             android:name=".MainActivity"
             android:launchMode="singleTop"

二进制
assets/images/guide1.png


二进制
assets/images/guide2.png


二进制
assets/images/guide3.png


二进制
assets/images/guide4.png


+ 10 - 25
lib/Screens/Guide/guide_screen.dart

@@ -16,43 +16,28 @@ class Guide extends StatefulWidget {
   _GuideScreenState createState() => _GuideScreenState();
 }
 
-class _GuideScreenState extends State<Guide>
-    with SingleTickerProviderStateMixin {
-  late AnimationController _controller;
-
+class _GuideScreenState extends State<Guide> {
   @override
   void initState() {
     super.initState();
-    _controller = AnimationController(vsync: this);
   }
 
   @override
   void dispose() {
     super.dispose();
-    _controller.dispose();
   }
 
   @override
   Widget build(BuildContext context) {
     return Container(
-      child: PageView.builder(
-        itemBuilder: _pageItemBuilder,
-        //当页面选中后回调此方法
-        onPageChanged: (int index) {
-          print("当前页面$index");
-        },
-        //值为flase时 显示第一个页面 然后从左向右开始滑动
-        //值为true时 显示最后一个页面 然后从右向左开始滑动
-        reverse: false,
-        //滑动到页面底部无回弹效果
-        physics: BouncingScrollPhysics(),
-        //横向滑动切换
-        scrollDirection: Axis.horizontal,
-      ),
-    );
-  }
-
-  Widget _pageItemBuilder(BuildContext context, int index) {
-    return Stack();
+        color: Colors.white,
+        child: PageView(
+          children: <Widget>[
+            Image(image: AssetImage('assets/images/guide1.png')),
+            Image(image: AssetImage('assets/images/guide2.png')),
+            Image(image: AssetImage('assets/images/guide3.png')),
+            Image(image: AssetImage('assets/images/guide4.png')),
+          ],
+        ));
   }
 }

+ 3 - 1
lib/main.dart

@@ -74,11 +74,13 @@ class _SplashScreenState extends State<SplashScreen> {
 
   @override
   Widget build(BuildContext context) {
-    SystemChrome.setEnabledSystemUIOverlays([]);
+    SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]); //隐藏顶部状态栏
     Size size = MediaQuery.of(context).size;
+    final EdgeInsets padding = MediaQuery.of(context).padding;
     return Container(
       height: size.height,
       width: double.infinity,
+      padding: EdgeInsets.fromLTRB(0, padding.top, 0, padding.bottom),
       color: Color(0xffc3eff2),
       constraints: BoxConstraints.expand(),
       child: Stack(