Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
state_example: flutter command viewmodel
class NotesViewModel {
NotesState state = NotesState.initial();
Command<String, String> inputChangedCommand;
Command<String, NotesState> updateNotesCommand;
NotesViewModel() {
inputChangedCommand = Command.createSync((x) => x, '');
updateNotesCommand = Command.createSync((input) {
state = state.copyWith(notes: state.notes.concat(input));
inputChangedCommand.execute('');
return state;
}, NotesState.initial());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment