Flutter: Show Splash Screen for 5 Seconds

8/17/2020 10:17:32 PM

Using Flutter to show a splash screen and then redirect to the default (home, main, etc) screen after 5 seconds.

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

class SplashScreen extends StatelessWidget {

  @override
  Widget build(BuildContext context) {

    new Future.delayed(const Duration(seconds: 5), () {
      Navigator.pushNamed(context, '/');
    });

    return Container(
      child:Scaffold(
        backgroundColor: Colors.lightBlueAccent,
        body: Center(
          child: Text("Welcome")
        ),
      ),
    );
  }
}