Skip to content
Snippets Groups Projects
Select Git revision
  • ae63e6b1b907335bf1110205359c37841394efb8
  • master default protected
  • 82-reword-settings
  • 67-improve-app-metadata
  • 54-improve-discoveries-page
  • 7-add-lastfm-link
  • Release_0.9.1_78 protected
  • Release_0.9.0_77 protected
  • Release_0.8.4_76 protected
  • Release_0.8.3_75 protected
  • Release_0.8.2_74 protected
  • Release_0.8.1_73 protected
  • Release_0.8.0_72 protected
  • Release_0.7.0_71 protected
  • Release_0.6.0_70 protected
  • Release_0.5.0_69 protected
  • Release_0.4.2_68 protected
  • Release_0.4.1_67 protected
  • Release_0.4.0_66 protected
  • Release_0.3.1_65 protected
  • Release_0.3.0_64 protected
  • Release_0.2.2_63 protected
  • Release_0.2.1_62 protected
  • Release_0.2.0_61 protected
  • Release_0.1.2_60 protected
  • Release_0.1.1_59 protected
26 results

main.dart

Blame
  • main.dart 2.71 KiB
    import 'dart:io';
    
    import 'package:easy_localization/easy_localization.dart';
    import 'package:flutter/material.dart';
    import 'package:flutter_bloc/flutter_bloc.dart';
    import 'package:hive/hive.dart';
    import 'package:hydrated_bloc/hydrated_bloc.dart';
    import 'package:path_provider/path_provider.dart';
    
    import 'package:scrobbles/config/theme.dart';
    import 'package:scrobbles/cubit/bottom_nav_cubit.dart';
    import 'package:scrobbles/cubit/data_counts_by_day_cubit.dart';
    import 'package:scrobbles/cubit/data_counts_by_hour_cubit.dart';
    import 'package:scrobbles/cubit/data_discoveries_cubit.dart';
    import 'package:scrobbles/cubit/data_statistics_global_cubit.dart';
    import 'package:scrobbles/cubit/data_statistics_recent_cubit.dart';
    import 'package:scrobbles/cubit/data_timeline_cubit.dart';
    import 'package:scrobbles/cubit/data_top_artists_cubit.dart';
    import 'package:scrobbles/ui/skeleton.dart';
    
    void main() async {
      /// Initialize packages
      WidgetsFlutterBinding.ensureInitialized();
      await EasyLocalization.ensureInitialized();
      final Directory tmpDir = await getTemporaryDirectory();
      Hive.init(tmpDir.toString());
      HydratedBloc.storage = await HydratedStorage.build(
        storageDirectory: tmpDir,
      );
    
      runApp(
        EasyLocalization(
          path: 'assets/translations',
          supportedLocales: const <Locale>[
            Locale('en'),
            Locale('fr'),
          ],
          fallbackLocale: const Locale('en'),
          useFallbackTranslations: true,
          child: const MyApp(),
        ),
      );
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MultiBlocProvider(
          providers: [
            BlocProvider<BottomNavCubit>(create: (context) => BottomNavCubit()),
            BlocProvider<DataCountsByDayCubit>(create: (context) => DataCountsByDayCubit()),
            BlocProvider<DataCountsByHourCubit>(create: (context) => DataCountsByHourCubit()),
            BlocProvider<DataDiscoveriesCubit>(create: (context) => DataDiscoveriesCubit()),
            BlocProvider<DataStatisticsGlobalCubit>(
                create: (context) => DataStatisticsGlobalCubit()),
            BlocProvider<DataStatisticsRecentCubit>(
                create: (context) => DataStatisticsRecentCubit()),
            BlocProvider<DataTimelineCubit>(create: (context) => DataTimelineCubit()),
            BlocProvider<DataTopArtistsCubit>(create: (context) => DataTopArtistsCubit()),
          ],
          child: MaterialApp(
            title: 'Scrobbles',
            theme: appTheme,
            home: const SkeletonScreen(),
    
            // Localization stuff
            localizationsDelegates: context.localizationDelegates,
            supportedLocales: context.supportedLocales,