Created
April 16, 2018 16:18
-
-
Save xrigau/d0a0ed6f02e259173601b2e31f690df2 to your computer and use it in GitHub Desktop.
Introduction to Redux in Flutter (to_do_list_page.dart viewmodel)
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 _ViewModel { | |
final String pageTitle; | |
final List<_ItemViewModel> items; | |
final Function onNewItem; | |
final String newItemToolTip; | |
_ViewModel(this.pageTitle, this.items, this.onNewItem, this.newItemToolTip, this.newItemIcon); | |
factory _ViewModel.create(Store<AppState> store) { | |
List<_ItemViewModel> items = store.state.toDos | |
.map((ToDoItem item) => /* Omitting some boilerplate here */) | |
.toList(); | |
return _ViewModel('To Do', items, () => store.dispatch(DisplayListWithNewItemAction()), 'Add new to-do item', Icons.add); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment