Last active
November 3, 2020 04:38
-
-
Save chimon2000/35bbbae285dc117d2713e578f6f38804 to your computer and use it in GitHub Desktop.
notes controller
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 "provider", which will store a reference to NotesController. | |
final notesProvider = StateNotifierProvider((ref) => NotesController()); | |
class NotesController extends StateNotifier<NotesState> { | |
NotesController() : super(NotesState.initial()); | |
void addNote() { | |
var notes = state.notes.concat(state.input); | |
state = state.copyWith(notes: notes, input: ''); | |
} | |
void updateInput(String input) => state = state.copyWith(input: input); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment