import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:lottie/lottie.dart'; import '../../../../core/utils/constants.dart'; import '../../../../injection_container.dart'; import '../bloc/authentication_bloc.dart'; class SplashPage extends StatefulWidget { const SplashPage({Key? key}) : super(key: key); @override // ignore: library_private_types_in_public_api _SplashPageState createState() => _SplashPageState(); } class _SplashPageState extends State { late String route = loginRoute; @override void initState() { super.initState(); Timer(const Duration(seconds: 6), () { context.go(route); }); } @override Widget build(BuildContext context) { return BlocProvider( create: (_) => di(), child: Scaffold( body: BlocListener( listener: (context, state) { if (state is Unauthenticated) { route = loginRoute; } if (state is Authenticated) { route = homeRoute; } }, child: Center(child: Lottie.asset(splashAnimation, repeat: false))), ), ); } }