Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Splash Screen in Flutter

What is Splash Screen?

Splash Screen is used to introduce your application. It is your first page in which you give introduction to your application.

How to Implement if?

So its very easy to create a splash screen in flutter, So Follow the following code to create a splash screen.

Let's Start Code:

Include this dependency  to create splash in pubspec.yaml.

 splashscreen: ^1.2.0

Step 1:

Include This code to main.dart file in your flutter project.

import 'package:flutter/material.dart';
import 'package:mynewflutte_app/Teast/sesrch.dart';
void main()=> runApp(MyApp());
class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primaryColor: Colors.green,
      ),
      home: MyApp1(),
    );
  }
}

Step 2:

Create a new dart file and give name as MySplashScreen and paste the code to create splash screen.

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

class MySplashScreen extends StatefulWidget {
  @override
  _MySplashScreenState createState() => new _MySplashScreenState();
}

class _MySplashScreenState extends State {
  @override
  Widget build(BuildContext context) {
    return new SplashScreen(
        seconds: 8,
        navigateAfterSeconds: new AfterSplash(),
        title: new Text('EasyCoding  A',
          style: new TextStyle(
              fontWeight: FontWeight.bold,
              fontSize: 20.0
          ),),
        image: new Image.asset('asset/flutter.jpg'),
        backgroundColor: Colors.white,
        styleTextUnderTheLoader: new TextStyle(),
        photoSize: 100.0,
        onClick: ()=>print("Flutter Egypt"),
        loaderColor: Colors.red
    );
  }
}

Step 3:

Create a new class and give name as AfterSplash. So when 5 seconds is over AfterSplash page is open. So this class is call when 5 seconds is finish.

class AfterSplash extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
          title: new Text("Welcome In SplashScreen Package"),
          automaticallyImplyLeading: false
      ),
      body: new Center(
        child: new Text("Done!",
          style: new TextStyle(
              fontWeight: FontWeight.bold,
              fontSize: 30.0
          ),),

      ),
    );
  }
}

Output:
      


                                

Want To Watch Video?












This post first appeared on AR Programming, please read the originial post: here

Share the post

Splash Screen in Flutter

×

Subscribe to Ar Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×