You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Using a parameter named state in generated family provider results in a compilation error.
To Reproduce
import'package:riverpod_annotation/riverpod_annotation.dart';
part'test_provider.g.dart';
enumSomeState { a, b }
@Riverpod(keepAlive:true)
boolwannaUseState(WannaUseStateRef ref, SomeState state) {
returntrue;
}
Results in:
./test_provider.g.dart:147:17: Error: The type 'SomeState' of the getter 'WannaUseStateRef.state' is not a subtype of the type 'bool' of the inherited setter 'ProviderRef.state'.
- 'SomeState' is from 'package:test/test_provider.dart' ('.test_provider.dart').
SomeState get state;
^^^^^
Expected behavior state is quite a common name so it should be allowed as parameter name.
The current workaround is to rename the variable to state_.
The text was updated successfully, but these errors were encountered:
Would you happen to know what are the other reserved keywords?
Maybe it's reasonable to briefly mention them in the Parameter restrictions section? (Sadly, I do not understand the riverpod code enough to list them all.)
An alternative solution could be to warn or fail during the code generation phase when a reserved keyword is used.
Describe the bug
Using a parameter named
state
in generated family provider results in a compilation error.To Reproduce
Results in:
Expected behavior
state
is quite a common name so it should be allowed as parameter name.The current workaround is to rename the variable to
state_
.The text was updated successfully, but these errors were encountered: