-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplash_page.dart
More file actions
37 lines (31 loc) · 1.02 KB
/
splash_page.dart
File metadata and controls
37 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'package:app/main/init.dart';
import 'package:domain/bloc/auth/auth_cubit.dart';
import 'package:flutter/material.dart';
class SplashPage extends StatefulWidget {
final bool instant;
const SplashPage({super.key, this.instant = true});
@override
State<SplashPage> createState() => _SplashPageState();
}
class _SplashPageState extends State<SplashPage> {
/// Given this is a global cubit, we can access it directly from getIt
/// otherwise use context.read<AuthCubit>() to read the Cubit under that context
AuthCubit get _authCubit => getIt();
@override
void initState() {
super.initState();
/// Add post frame callback to avoid calling bloc methods during build
WidgetsBinding.instance.addPostFrameCallback((_) async {
await Future.delayed(Duration(seconds: widget.instant ? 0 : 2));
_authCubit.onValidate();
});
}
@override
Widget build(BuildContext context) {
return const Material(
child: Center(
child: CircularProgressIndicator(),
),
);
}
}