Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2020 06:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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));
return state;
}, NotesState.initial());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment