Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
notes controller
// 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