-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathsplash_page.dart
45 lines (38 loc) · 1.08 KB
/
splash_page.dart
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
38
39
40
41
42
43
44
45
// ignore_for_file: use_build_context_synchronously
import 'package:ai_buddy/core/extension/context.dart';
import 'package:ai_buddy/core/navigation/route.dart';
import 'package:ai_buddy/core/util/secure_storage.dart';
import 'package:flutter/material.dart';
class SplashPage extends StatefulWidget {
const SplashPage({super.key});
@override
State<SplashPage> createState() => _SplashPageState();
}
class _SplashPageState extends State<SplashPage> {
final SecureStorage secureStorage = SecureStorage();
@override
void initState() {
super.initState();
_navigateToNextPage();
}
Future<void> _navigateToNextPage() async {
final String? apiKey = await secureStorage.getApiKey();
if (apiKey == null || apiKey.isEmpty) {
AppRoute.welcome.go(context);
} else {
AppRoute.home.go(context);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(
'AI Buddy',
textAlign: TextAlign.center,
style: context.textTheme.headlineLarge,
),
),
);
}
}