Skip to content
Snippets Groups Projects
splashscreen.dart 2.13 KiB
Newer Older
  • Learn to ignore specific revisions
  • Markin Igor's avatar
    Markin Igor committed
    import 'dart:core';
    import 'dart:async';
    import 'package:flutter/material.dart';
    
    class SplashScreen extends StatefulWidget {
      final dynamic navigateAfterFuture;
      SplashScreen({this.navigateAfterFuture});
    
      @override
      _SplashScreenState createState() => _SplashScreenState();
    }
    
    class _SplashScreenState extends State<SplashScreen> {
      @override
      void initState() {
        super.initState();
    
        load();
      }
    
      load() async {
        var newWidget = await widget.navigateAfterFuture();
    
        // Show loader additional 2 seconds
        Timer(
    
          Duration(seconds: 1),
    
    Markin Igor's avatar
    Markin Igor committed
            () {
              Navigator.of(context).pushReplacement(new MaterialPageRoute(builder: (BuildContext context) => newWidget));
            }
        );
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: new InkWell(
            child:new Stack(
              fit: StackFit.expand,
              children: <Widget>[
                new Container(
                  decoration: new BoxDecoration(
                    color: Color(0xFFd51d32),
                  ),
                ),
                new Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: <Widget>[
                    new Expanded(
                      flex: 2,
                      child: new Container(
                          child: new Image.asset('assets/images/vereign_logo_text.png'),
                          padding: EdgeInsets.all(40)
                      ),
                    ),
                    Expanded(
                      flex: 1,
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
    
                          CircularProgressIndicator(
                            valueColor: new AlwaysStoppedAnimation<Color>(Colors.white),
                          ),
                          Padding(
                            padding: const EdgeInsets.only(top: 20.0),
                          ),
                          new Text('Loading', style: new TextStyle(
                              color: Colors.white
                          ))
                        ],
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        );
      }
    }