Skip to content

Instantly share code, notes, and snippets.

@felangel felangel/main.dart
Created Mar 16, 2019

Embed
What would you like to do?
[flutter_todos] todos app
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
You can’t perform that action at this time.