animated_splash 1.0.0

Animated Splash Screen #

Using the package #

Get the library

environment:
  sdk: ">=2.1.0 <3.0.0"

Add dependency in pubspec.yaml

dependencies:
  animated_splash: ^1.0.0

Things to do #

  1. Get a logo for your app
  2. Prepare what to execute while the splash screen is shown (initializing your db, shared preferences, firebase...etc)
  3. Screen to be shown after splash screen and background process
  4. Duration of Splash Screen

Import the package

import 'package:animated_splash/animated_splash.dart';

Show splash screen for some duration #

  type: AnimatedSplashType.StaticDuration

Inside your main function, use home as SplashScreen(_), the parameters are as follows:

imagePath: Path to your app-logo/image home: Screen to be shown after splash duration: duration of splash screen in milliseconds type

runApp(MaterialApp(
  home: AnimatedSplash(
              imagePath: 'assets/flutter_icon.png',
              home: Home(),
              duration: 2500,
              type: AnimatedSplashType.StaticDuration,
            ),
));

Execute a function in background and based on the value from that function navigate to different screen #

  type: AnimatedSplashType.BackgroundProcess

Create an object of Function that gets executed while splash screen is shown

Function duringSplash = () {
  //Write your code here
  ...
  return value;
};

Create routes according to your function return value

  //setup the return value correctly for proper navigation
  Map<dynamic, Widget> returnValueAndHomeScreen = {1: Home(), 2: HomeSt()};

Inside your main function, use home as SplashScreen(_), the parameters are as follows:

imagePath: Path to your app-logo/image home: Screen to be shown after splash customFunction: the function you have written above duration: duration of splash screen in milliseconds type output value of customFunction and home screen to navigate(Map function)

runApp(MaterialApp(
  home: AnimatedSplash(
              imagePath: 'assets/flutter_icon.png',
              home: Home(),
              customFunction: duringSplash,
              duration: 2500,
              type: AnimatedSplashType.BackgroundProcess,
              outputAndHome: op,
            ),
));

Demo #

ProgressDialog Demo

[1.0.0] - Added Navigation to different screens based on the output value from the function passed

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/README.md


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

void main() {
  Function duringSplash = () {
    print('Something background process');
    int a = 123 + 23;
    print(a);

    if (a > 100)
      return 1;
    else
      return 2;
  };

  Map<int, Widget> op = {1: Home(), 2: HomeSt()};

  runApp(MaterialApp(
    home: AnimatedSplash(
      imagePath: 'assets/flutter_icon.png',
      home: Home(),
      customFunction: duringSplash,
      duration: 2500,
      type: AnimatedSplashType.BackgroundProcess,
      outputAndHome: op,
    ),
  ));
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Home'),
        ),
        body: Center(
            child: Text('My Cool App',
                style: TextStyle(color: Colors.black, fontSize: 20.0))));
  }
}

class HomeSt extends StatefulWidget {
  @override
  _HomeStState createState() => _HomeStState();
}

class _HomeStState extends State<HomeSt> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Home'),
        ),
        body: Center(
            child: Text('My Cool App home page 2',
                style: TextStyle(color: Colors.black, fontSize: 20.0))));
  }
}



Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  animated_splash: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:animated_splash/animated_splash.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
78
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test

Admin