riverpod
riverpod copied to clipboard
Consider doing a configurable replace on generated providers
Is your feature request related to a problem? Please describe.
Often times, when creating a class provider, you may want to have somethingProvider
.
To do this, you would have to name the class Something
However, what if the state of your class is also called Something
?
You could rename the notifier, but then the resulting provider would no longer be called somethingProvider
Describe the solution you'd like
Consider stripping Notifier
from class names to allow the distinction
Perhaps that could be an option in @Riverpod()
? (probably opt-in? perhaps add a global option to change the default?)
Perhaps even a manual rename parameter to specify the exact resulting name?
Describe alternatives you've considered
Simply aliasing the incorrectly named generated provider
final somethingProvider = somethingNotifierProvider;
This has the caveat of breaking riverpod_lints
unless you apply the @ProviderFor(...)
internal annotation yourself
Additional context
class Data {}
// we want: dataProvider
// what's generated: dataNotifierProvider
// we are forced to:
final dataProvider = dataNotifierProvider; // breaks lints unless we add @ProviderFor(DataNotifier)
@riverpod
class DataNotifier extends _$DataNotifier {
Data build() => Data();
...
}