import 'package:flutter/material.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:fluro/fluro.dart'; import 'package:imagini/core/app_provider.dart'; import 'package:imagini/blocs/splash_bloc.dart'; import 'package:imagini/graphql/imagini_graphql.dart'; class SplashScreen extends StatefulWidget { static const String PATH = '/'; SplashScreen({Key key}) : super(key: key); @override _SplashScreenState createState() => _SplashScreenState(); } class _SplashScreenState extends State { SplashBloc bloc; @override void dispose() { super.dispose(); bloc.dispose(); } @override Widget build(BuildContext context) { _init(); return Scaffold( body: Center( child: ConstrainedBox( constraints: BoxConstraints(maxWidth: 500), child: Container( margin: EdgeInsets.fromLTRB(50, 0, 50, 0), height: 270, child: Column( children: [ Container( child: FittedBox( fit: BoxFit.contain, child: const FlutterLogo(), ), width: 175, margin: EdgeInsets.fromLTRB(0, 0, 0, 50), ), PlatformCircularProgressIndicator() ], ), ), ), ), ); } void _init(){ if(null == bloc){ bloc = SplashBloc(AppProvider.getApplication(context)); bloc.loginResult.listen((Login$Query$AuthResponse lr) { if (lr.result != AuthResult.success) { AppProvider.getRouter(context).navigateTo(context, "/Home", transition: TransitionType.fadeIn); } else { AppProvider.getRouter(context).navigateTo(context, "/Login", transition: TransitionType.fadeIn); } }); } } }