Last active
November 3, 2020 05:29
-
-
Save chimon2000/62a84c981508a7a01d8716f7eb41ff79 to your computer and use it in GitHub Desktop.
state_example: notes viewlogic
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
// 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