Flutter hold splash screen for 3 Seconds. How to implement splash screen in Flutter?

前端 未结 9 2002
后悔当初
后悔当初 2021-02-16 00:16

How to show splash screen in flutter for 3 seconds and then go next my login screen.

I have tried.countdowntimer but import is unresolved

import \'pack         


        
9条回答
  •  旧巷少年郎
    2021-02-16 00:24

    refer bellow main.dart

    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 {
      @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: [
              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,
              ),
            ]),
          ),
        );
      }
    }
    

    Hope this will helps you

提交回复
热议问题