55 lines
1.1 KiB
Dart
55 lines
1.1 KiB
Dart
|
|
import 'dart:async';
|
||
|
|
|
||
|
|
import 'package:cb_prestige_qr/core/utils/MainShell.dart';
|
||
|
|
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;
|
||
|
|
Navigator.of(context).pushReplacement(
|
||
|
|
MaterialPageRoute(builder: (_) => const MainShell()),
|
||
|
|
);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
void dispose() {
|
||
|
|
_timer?.cancel();
|
||
|
|
super.dispose();
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Scaffold(
|
||
|
|
body: SizedBox.expand(
|
||
|
|
child: Image.asset(
|
||
|
|
widget.imageAssetPath,
|
||
|
|
fit: BoxFit.cover,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|