riverpod
riverpod copied to clipboard
riverpod_generator: Make `build` optional in the class syntax
Support:
@riverpod
class Foo extends _$Foo {
}
Foo value = ref.watch(fooProvider);
@riverpod
class Foo extends _$Foo {
void build() {this.a = ref.watch(something);}
}
Foo value = ref.watch(fooProvider);
@riverpod
class Foo extends _$Foo {
Future<void> build() async {this.a = ref.watch(something);}
}
AsyncValue<Foo> value = ref.watch(fooProvider);
Foo value = ref.watch(fooProvider.notifier);
@rrousselGit Do you mind if I create a PR doing this?
I have some experience with code generation and I think this one should be simple to implement.
I still need to think this through. It's unclear to me whether this is truly desired.
Cool! I'll keep watching this issue then.