import 'package:fast_cached_network_image/fast_cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:just_audio_background/just_audio_background.dart'; import 'package:just_audio_media_kit/just_audio_media_kit.dart'; import 'package:ocarina/views/home_view.dart'; import 'package:ocarina/widgets/player.dart'; import 'package:responsive_sizer/responsive_sizer.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() async { JustAudioMediaKit.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized(); await JustAudioBackground.init( androidNotificationChannelId: 'wtf.caras.ocarina.bg_playback', androidNotificationChannelName: 'Ocarina playback', androidNotificationOngoing: true, ); await FastCachedImageConfig.init(clearCacheAfter: const Duration(days: 31)); sp = await SharedPreferences.getInstance(); runApp(const MyApp()); } /// [GlobalKey] used to set the [Player]'s state from other code final playerKey = GlobalKey(); /// Instance of [SharedPreferences] used to get shared preferences late final SharedPreferences sp; class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return ResponsiveSizer( builder: (context, orientation, screenType) { return MaterialApp( title: 'Ocarina', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const HomeView(), builder: (context, child) { return Stack( children: [ child!, Player( key: playerKey, ), ], ); }, ); }, ); } }