diff --git a/lib/main.dart b/lib/main.dart index 95dc1fb..95ad6f6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:fnotes/notes.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:fnotes/persistence_bloc.dart'; import 'package:fnotes/theme_bloc.dart'; void main() { @@ -12,8 +13,11 @@ class MainApp extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( - create: (context) => ThemeBloc(), + return MultiBlocProvider( + providers: [ + BlocProvider(create: (context) => ThemeBloc()), + BlocProvider(create: (context) => PersistenceBloc()) + ], child: BlocBuilder( builder: (context, state) { return MaterialApp( diff --git a/lib/persistence_bloc.dart b/lib/persistence_bloc.dart new file mode 100644 index 0000000..539536c --- /dev/null +++ b/lib/persistence_bloc.dart @@ -0,0 +1,27 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + +class PersistenceBloc extends Bloc { + PersistenceBloc() : super(PersistenceState.init()) { + on(storeAllNotes); + on(loadAllNotes); + } + + void storeAllNotes(PersistenceEvent event, Emitter emit) {} + void loadAllNotes(PersistenceEvent event, Emitter emit) {} +} + +class PersistenceEvent {} + +class LoadNotesEvent extends PersistenceEvent {} + +class StoreNotesEvent extends PersistenceEvent {} + +class PersistenceState { + int lastIndex; + + PersistenceState({required this.lastIndex}); + + factory PersistenceState.init() { + return PersistenceState(lastIndex: 0); + } +}