Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
state_example: notes viewlogic
// We create a "logic ref", which will store a reference to NotesViewLogic.
final notesViewLogicRef = LogicRef((scope) => NotesViewLogic(scope));
class NotesViewLogic with Logic {
const NotesViewLogic(this.scope);
@override
final Scope scope;
void addNote() {
var state = read(notesRef);
write(notesRef,
state.copyWith(notes: state.notes.concat(state.input), input: ''));
}
void updateInput(String input) =>
write(notesRef, read(notesRef).copyWith(input: input));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment