Splash Screen in Flutter


We are going to Explain About Splash Screen In Flutter. Please follow the Following step given Below.


Step1.

Write click on flutter App(root)and click on directory.open dialog box then give  name is images paste any images here.




We need to import the image files into the project. It is common practice to put image files in a images or assets folder at the root of a Flutter project.

Step 2.

Flutter actually gives a simpler way to add Splash Screen to our application.
In lib folder you just create dart name is home.dart



Step :3

In Main.dart Class you just write this code given below

import 'package:flutter/material.dart';
import 'package:flutter_app/home.dart';

void main() {
  runApp(new MaterialApp(
    home: new SplashScreen(),

    routes: <String, WidgetBuilder>{
      '/HomeScreen': (BuildContext context) => new HomeScreen()
    },
  ));
}

class SplashScreen extends StatefulWidget {
  @override
  _SplashScreenState createState() => new _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  startTime() async {
    var _duration = new Duration(seconds: 5);
    return new Timer(_duration, navigationPage);
  }

  void navigationPage() {
    Navigator.of(context).pushReplacementNamed('/HomeScreen');
  }

  @override
  void initState() {
    super.initState();
    startTime();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Center(
        child: new Image.asset('images/flutter.jpg'),
        
      ),
    );
  }

Full Code Download 

Splash Screen in Flutter





Post a Comment

0 Comments