Created
March 16, 2019 18:39
-
-
Save felangel/cf9ab023aa29c26bff0df67a31d898f6 to your computer and use it in GitHub Desktop.
[flutter_todos] todos app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TodosApp extends StatelessWidget { | |
final todosBloc = TodosBloc( | |
todosRepository: const TodosRepositoryFlutter( | |
fileStorage: const FileStorage( | |
'__flutter_bloc_app__', | |
getApplicationDocumentsDirectory, | |
), | |
), | |
); | |
@override | |
Widget build(BuildContext context) { | |
return BlocProvider( | |
bloc: todosBloc, | |
child: MaterialApp( | |
title: FlutterBlocLocalizations().appTitle, | |
theme: ArchSampleTheme.theme, | |
localizationsDelegates: [ | |
ArchSampleLocalizationsDelegate(), | |
FlutterBlocLocalizationsDelegate(), | |
], | |
routes: { | |
ArchSampleRoutes.home: (context) { | |
return HomeScreen( | |
onInit: () => todosBloc.dispatch(LoadTodos()), | |
); | |
}, | |
ArchSampleRoutes.addTodo: (context) { | |
return AddEditScreen( | |
key: ArchSampleKeys.addTodoScreen, | |
onSave: (task, note) { | |
todosBloc.dispatch( | |
AddTodo(Todo(task, note: note)), | |
); | |
}, | |
isEditing: false, | |
); | |
}, | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment