import 'package:flutter/material.dart'; import 'dart:async'; import 'package:flutter_svg/svg.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../components/background.dart'; import '../constants.dart'; class SplashScreen extends StatefulWidget { @override _SplashScreenState createState() => _SplashScreenState(); } class _SplashScreenState extends State { Future checkLoad() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); kEmptySocial = (prefs.getString('emptySocial') ?? null ); if( kEmptySocial != null ){ kEmptySocial = (prefs.getString('emptySocial') ?? null ); kEmptyAccessToken = (prefs.getString('emptyAccessToken') ?? null ); kEmptyId = (prefs.getString('emptyId') ?? null ); kEmptyName = (prefs.getString('emptyName') ?? null ); kEmptyEmail = (prefs.getString('emptyEmail') ?? null ); kEmptyImage = (prefs.getString('emptyImage') ?? null ); } Navigator.pushNamedAndRemoveUntil(context, '/main', ModalRoute.withName('/main')); // Navigator.pushNamedAndRemoveUntil(context, '/login', ModalRoute.withName('/login')); } @override void initState() { // TODO: implement initState super.initState(); new Future.delayed(const Duration(seconds: 1), () { checkLoad(); }); } @override Widget build(BuildContext context) { Size size = MediaQuery.of(context).size; return Background( image: Container( height: size.height, width: size.width, decoration: BoxDecoration( image: DecorationImage( image: AssetImage('assets/images/splash_bg.png'), fit: BoxFit.cover ) ), ), child: Scaffold( backgroundColor: Colors.transparent, body: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SvgPicture.asset( "assets/images/logo.svg", height: size.height * 0.4, ), SizedBox(height: size.height * 0.1), Center(child: CircularProgressIndicator()), SizedBox(height: size.height * 0.03), Text('Loading...',style: Theme.of(context).textTheme.bodyText1,), ], ), ), ); } }