Untitled
unknown
plain_text
4 years ago
2.8 kB
3
Indexable
const Duration _splashDuration = Duration(seconds: 2); class SplashScreen extends StatefulWidget { @override _SplashScreenState createState() => _SplashScreenState(); } class _SplashScreenState extends State<SplashScreen> { @override void initState() { super.initState(); var _autoLoginProvider = locator<AutoLoginProvider>(); Timer(_splashDuration, () async { _autoLoginProvider.isAlreadyLoggedIn(); switch (_autoLoginProvider.state) { case Status.Authenticated: UserModel _userModel = await _autoLoginProvider.getCurrentUserData(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => HomePage( arguments: HomePageArguments( _userModel.type!, _userModel.pushToken!, ), ), ), ); break; case Status.Unauthenticated: Navigator.pushReplacementNamed(context, Routes.auth); break; case Status.Error: showInSnackBar(context, _autoLoginProvider.message); break; } }); } @override Widget build(BuildContext context) { /************************************************************************/ /* Content of Splash Screen */ /************************************************************************/ return Scaffold( body: Container( height: double.maxFinite, width: double.maxFinite, decoration: BoxDecoration( gradient: Constants.gradient, ), child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { return Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ Logo( width: constraints.maxWidth / 1.5, height: constraints.maxHeight / 3.0, imagePath: Constants.logo, ), Text( "Welcome!", style: TextStyle( color: Colors.white, fontSize: 20, fontWeight: FontWeight.w700, ), ), CircularProgressIndicator( valueColor: new AlwaysStoppedAnimation<Color>( Colors.white, ), ), ], ); }, ), ), ); } }
Editor is loading...