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

add provider family name suffix option #2274

Merged
merged 5 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/riverpod_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## Unreleased patch
## Unreleased minor

Deprecate the (new) shorthand syntax for scoping provider using the `external`
keyword. That syntax unfortunately does not work on web and therefore will be removed.
- Added support for configuring the name of providers with parameters ("families") (thanks to @K9i-0)

- Deprecate the (new) shorthand syntax for scoping provider using the `external`
keyword. That syntax unfortunately does not work on web and therefore will be removed.

## 2.0.0

Expand Down
4 changes: 4 additions & 0 deletions packages/riverpod_generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ targets:
# Could be changed to "Pod", such that riverpod_generator
# would generate "countPod" instead of "countProvider"
provider_name_suffix: "Provider" # (default)
# Similar to provider_name_sufix, this is an option for renaming
# providers with parameters ("families").
# This takes precedence over provider_name_suffix.
provider_family_name_suffix: "Provider" # (default)
```

[family]: https://riverpod.dev/docs/concepts/modifiers/family
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ targets:
builders:
riverpod_generator:
options:
provider_name_suffix: 'Pod'
provider_name_suffix: 'Pod'
provider_family_name_suffix: 'ProviderFamily'
52 changes: 52 additions & 0 deletions packages/riverpod_generator/integration/build_yaml/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ FutureOr<int> countFuture(CountFutureRef ref) {
return 1;
}

@riverpod
Stream<int> countStream(CountStreamRef ref) {
return Stream.value(1);
}

@riverpod
class CountNotifier extends _$CountNotifier {
@override
Expand All @@ -27,3 +32,50 @@ class CountAsyncNotifier extends _$CountAsyncNotifier {
return 1;
}
}

@riverpod
class CountStreamNotifier extends _$CountStreamNotifier {
@override
Stream<int> build() {
return Stream.value(1);
}
}

@riverpod
int count2(Count2Ref ref, int a) {
return 1;
}

@riverpod
FutureOr<int> countFuture2(CountFuture2Ref ref, int a) {
return 1;
}

@riverpod
Stream<int> countStream2(CountStream2Ref ref, int a) {
return Stream.value(1);
}

@riverpod
class CountNotifier2 extends _$CountNotifier2 {
@override
int build(int a) {
return 1;
}
}

@riverpod
class CountAsyncNotifier2 extends _$CountAsyncNotifier2 {
@override
FutureOr<int> build(int a) {
return 1;
}
}

@riverpod
class CountStreamNotifier2 extends _$CountStreamNotifier2 {
@override
Stream<int> build(int a) {
return Stream.value(1);
}
}
Loading