颤动的飞溅屏幕

时间:2018-04-05 09:37:45

标签: dart flutter splash

如何在颤动时显示闪屏?所以有一个启动图标选项。我在各自的文件夹中添加了ios和android的图像。我的问题是它太快了。所以它直接打开MyApp()。我希望我的应用程序不显示任何内容,让溅起控制权,直到我找出要将用户带到哪个屏幕(在MyApp中我想要进行初始化)

2 个答案:

答案 0 :(得分:5)

您可以在initState中使用class SplashScreen extends StatefulWidget { @override _SplashScreenState createState() => new _SplashScreenState(); } class _SplashScreenState extends State<SplashScreen> { @override void initState (){ super.initState(); // TODO initial state stuff new Future.delayed(const Duration(seconds: 4)); } @override Widget build(BuildContext context) { //build } } 构造函数。这将使您的SplashScreen在导航发生之前保持指定的持续时间。

SELECT coord_name, count(*) total_count
FROM customerlocation
WHERE X_Coord < 50 OR (Y_Coord < 50)
GROUP BY X_Coord, Y_Coord

答案 1 :(得分:1)

小更新到aziza答案

import 'dart:async';    
import 'package:flutter/material.dart';    
import 'src/login_screen.dart';

void main() {
  runApp(new MaterialApp(
    home: new MyApp(),
  ));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    new Future.delayed(
        const Duration(seconds: 3),
        () => Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => LoginScreen()),
            ));
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      backgroundColor: Colors.white,
      body: Container(
        child: new Column(children: <Widget>[
          Divider(
            height: 240.0,
            color: Colors.white,
          ),
          new Image.asset(
            'assets/logo.png',
            fit: BoxFit.cover,
            repeat: ImageRepeat.noRepeat,
            width: 170.0,
          ),
          Divider(
            height: 105.2,
            color: Colors.white,
          ),
        ]),
      ),
    );
  }
}

希望这对其他人也有帮助:)