import 'package:auto_orientation/auto_orientation.dart'; import 'package:flutter/material.dart'; import 'package:just_audio/just_audio.dart'; import 'package:ontime_haulers/screens/home_screen.dart'; import 'package:ontime_haulers/screens/quote_screen.dart'; import 'package:ontime_haulers/screens/track_screen.dart'; import 'package:ontime_haulers/screens/login_screen.dart'; import 'package:ontime_haulers/screens/setup_screen.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatefulWidget { const MyApp({super.key}); @override State createState() => _MyAppState(); } class _MyAppState extends State { int _selectedIndex = 0; bool _isLoading = true; void _onItemTapped(int index) { setState(() { _selectedIndex = index; if (index == 1) { AutoOrientation.landscapeRightMode(); } else { AutoOrientation.portraitUpMode(); } }); } _setScreen() { switch (_selectedIndex) { case 0: return HomeScreen( selectedIndex: _selectedIndex, onItemTapped: _onItemTapped, ); case 1: return QuoteScreen( selectedIndex: _selectedIndex, onItemTapped: _onItemTapped, ); case 2: return TrackScreen( selectedIndex: _selectedIndex, onItemTapped: _onItemTapped, ); case 3: return LoginScreen( selectedIndex: _selectedIndex, onItemTapped: _onItemTapped, ); case 4: return SetupScreen( selectedIndex: _selectedIndex, onItemTapped: _onItemTapped, ); default: return HomeScreen( selectedIndex: _selectedIndex, onItemTapped: _onItemTapped, ); } } late AudioPlayer player; @override void initState() { super.initState(); player = AudioPlayer(); _playAudio(); // Simulate a loading delay Future.delayed(const Duration(seconds: 7), () { setState(() { _isLoading = false; }); }); } Future _playAudio() async { await player.setAsset('assets/splash.mp3'); player.play(); } @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: _isLoading ? Scaffold( backgroundColor: Colors.red, body: Container( width: double.infinity, height: double.infinity, decoration: BoxDecoration( image: DecorationImage(image: AssetImage('assets/ot.gif'), fit: BoxFit.cover, ), ), ), ) : _setScreen(), ); } }