cb_prestige_qr/lib/features/splash/presentation/pages/splash_screen.dart

51 lines
1.1 KiB
Dart
Raw Normal View History

2026-04-09 06:47:03 +00:00
import 'dart:async';
2026-04-27 09:08:26 +00:00
import 'package:cb_prestige_qr/app/navigation/main_shell.dart';
2026-04-09 06:47:03 +00:00
import 'package:flutter/material.dart';
class SplashScreen extends StatefulWidget {
const SplashScreen({
super.key,
this.duration = const Duration(seconds: 2),
this.imageAssetPath = 'assets/images/splash_1.png',
});
final Duration duration;
final String imageAssetPath;
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
Timer? _timer;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_timer = Timer(widget.duration, () {
if (!mounted) return;
2026-04-27 09:08:26 +00:00
Navigator.of(
context,
).pushReplacement(MaterialPageRoute(builder: (_) => const MainShell()));
2026-04-09 06:47:03 +00:00
});
});
}
@override
void dispose() {
_timer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SizedBox.expand(
2026-04-27 09:08:26 +00:00
child: Image.asset(widget.imageAssetPath, fit: BoxFit.cover),
2026-04-09 06:47:03 +00:00
),
);
}
}