import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:fnotes/notes_app.dart'; import 'package:fnotes/persisted_brightness.dart'; import 'package:fnotes/persistent_notes_bloc.dart'; import 'package:fnotes/theme_bloc.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); //for drift PersistedBrightness persistedBrightness = await PersistedThemeBloc.getPersistedBrightness(); runApp(MainApp(brightness: persistedBrightness.toFlutterBrightness())); } class MainApp extends StatelessWidget { final Brightness brightness; const MainApp({super.key, required this.brightness}); @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ BlocProvider(create: (context) => PersistedThemeBloc(brightness)), BlocProvider(create: (context) => PersistentNotesBloc()), ], child: BlocBuilder( builder: (context, state) { return MaterialApp( theme: state.theme, home: const NotesApp(), ); }, ), ); } }