51 lines
1.3 KiB
Dart
51 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'pages/splashscreen_page.dart'; // Import splash screen
|
|
import 'pages/onboarding_pages.dart'; // Import halaman onboarding
|
|
import 'pages/home_page.dart'; // Import halaman utama
|
|
|
|
void main() {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatefulWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
State<MyApp> createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends State<MyApp> {
|
|
bool _isFirstTime = true;
|
|
bool _isLoading = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_checkFirstTime();
|
|
}
|
|
|
|
Future<void> _checkFirstTime() async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
bool? hasSeenOnboarding = prefs.getBool('hasSeenOnboarding');
|
|
|
|
setState(() {
|
|
_isFirstTime = hasSeenOnboarding == null || !hasSeenOnboarding;
|
|
_isLoading = false;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
home: _isLoading
|
|
? const Scaffold(
|
|
body: Center(child: CircularProgressIndicator()),
|
|
)
|
|
: SplashScreen(isFirstTime: _isFirstTime),
|
|
);
|
|
}
|
|
}
|