Skip to content

Instantly share code, notes, and snippets.

@chimon2000
Last active November 3, 2020 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chimon2000/35bbbae285dc117d2713e578f6f38804 to your computer and use it in GitHub Desktop.
Save chimon2000/35bbbae285dc117d2713e578f6f38804 to your computer and use it in GitHub Desktop.
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