Closed dogomayana closed 1 month ago
The todo example is correct. You used autoDispose, when the example does not.
I didn't explicitly use the autoDispose. I copied the exact code from the TODO example and ran the build-runner which generated the autoDispose.
You used AutoDisposeNotifierProvider
in your code snippet, which isn't used anywhere in the documentation
class TodoList extends Notifier<List> {
@override
List build() => [
const Todo(id: 'todo-0', description: 'Buy cookies'),
const Todo(id: 'todo-1', description: 'Star Riverpod'),
const Todo(id: 'todo-2', description: 'Have a walk'),
];
void add(String description) { state = [ ...state, Todo( id: _uuid.v4(), description: description, ), ]; } ... The "extend Notifier" throws a subclass error when build-runner run, this means, the "Notifier" is not the right notifier for that instance.
This worked for me.
In summary, substitute "Notifier" with "AutoDisposeNotifier".