Set groundwork for persisting notes
This commit is contained in:
parent
12940beab7
commit
55957b04db
@ -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<ThemeBloc, ThemeState>(
|
||||
builder: (context, state) {
|
||||
return MaterialApp(
|
||||
|
27
lib/persistence_bloc.dart
Normal file
27
lib/persistence_bloc.dart
Normal file
@ -0,0 +1,27 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class PersistenceBloc extends Bloc<PersistenceEvent, PersistenceState> {
|
||||
PersistenceBloc() : super(PersistenceState.init()) {
|
||||
on<StoreNotesEvent>(storeAllNotes);
|
||||
on<LoadNotesEvent>(loadAllNotes);
|
||||
}
|
||||
|
||||
void storeAllNotes(PersistenceEvent event, Emitter<PersistenceState> emit) {}
|
||||
void loadAllNotes(PersistenceEvent event, Emitter<PersistenceState> 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user