title: Splash screen implementation in flutter
body: <p>I am new to Flutter and I wanted to have splash screen in my app. I used initState() and the navigator. But it didn't work. The app opens the splashscreen appears but after that it does not navigate to the next screen. </p>
  
  <p>My main.dart</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:bmi/HomePage.dart';
  import 'dart:async';
  
  main(){
    runApp(MyApp());
   }
  
   class MyApp extends StatelessWidget{
   @override
   Widget build(BuildContext context) {
      return SplashScreen();
   }
  }
  
  class SplashScreen extends StatefulWidget{
    @override
    State&lt;StatefulWidget&gt; createState() {
      return SplashScreenState();
    }
  }
  
  class SplashScreenState extends State&lt;SplashScreen&gt;{
    @override
    void initState() {
      super.initState();
      Future.delayed(
        Duration(
          seconds: 4
        ),
        (){
          Navigator.push(
            context,
            MaterialPageRoute(
              builder: (context) =&gt; HomePage(),
            )
          );
        }
    );
  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.red,
        body: Text(
          'Welcome to BMI Calculator',
          style: new TextStyle(
            fontSize: 15.0,
            color: Colors.white,
            fontWeight: FontWeight.bold
          ),
        ),
      ),
    );
  }
  }
  </code></pre>
  
  <p>And my HomePage.dart</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class HomePage extends StatelessWidget{
     @override
     Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              backgroundColor: Colors.red,
               title: Text(
                'BMI Calculator',
                 style: new TextStyle(
                   color: Colors.white
                 ),
              ),
            ),
          ),
        );
      }
    }
  </code></pre>
  
  <p>How can I resolve this?</p>
  
  <p>Since I am new to flutter I dont know whether this is the right way to implement splashScreen if there are any other easier ways can you please suggest that also.</p>
  
  <p>Thank you in advance.</p>