Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The getter 'state' isn't defined for the class 'StateNotifierProvider' for newer Riverpod versions #1

Open
iotanbo opened this issue Apr 20, 2021 · 5 comments

Comments

@iotanbo
Copy link

iotanbo commented Apr 20, 2021

First of all, thanks for the excellent tutorial! It works fine as is, but after updating to
flutter_riverpod: ^0.14.0+1 the following errors appear:

ERROR: lib/presentation/weather_search_page.dart:23:45: Error: The getter 'state' isn't defined for the class 'StateNotifierProvider<WeatherNotifier, dynamic>'

ERROR: lib/presentation/weather_search_page.dart:37:59: Error: The getter 'state' isn't defined for the class 'StateNotifierProvider<WeatherNotifier, dynamic>'

Because this is a tutorial follow by many, I believe it's important to check whether
it is a minor syntax change or something more profound.

@iotanbo
Copy link
Author

iotanbo commented Apr 21, 2021

Indeed, syntax of StateNotifierProvider has changed in version 0.14 as could be seen in the official repo: https://github.com/rrousselGit/river_pod/blob/master/examples/todos/lib/main.dart.

final todos = ref.watch(todoListProvider);
context.read(todoListProvider.notifier).add(value);

But the documenatation of the Riverpod package is not yet updated.

@iotanbo
Copy link
Author

iotanbo commented Apr 21, 2021

Actually, here is a migration guide:
https://riverpod.dev/docs/migration/0.13.0_to_0.14.0

@daniil-shumko
Copy link

Anyone interested in the working project with riverpod version 0.14.0+3 please see this commit on my fork of this repo daniil-shumko@6a6f700

@aboutandre
Copy link

@daniil-shumko maybe you could create a PR?

@daniil-shumko
Copy link

@aboutandre only if @ResoDev is happy with the changes. He will also probably will have to update his video/blog post for this so that the code matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants