riverpod-family
Installation
SKILL.md
Riverpod — Family
Instructions
Family lets a single provider have multiple independent states, one per parameter combination (like a Map from parameter to state). Use it for API calls that depend on an ID, query, or page number.
Creating a family (functional)
Add .family and an extra type parameter for the argument. The provider function receives (ref, param):
final userProvider = FutureProvider.autoDispose.family<User, String>((ref, id) async {
final dio = Dio();
final response = await dio.get('https://api.example.com/users/$id');
return User.fromJson(response.data);
});
With code generation, add parameters to the function; the generated provider accepts arguments: userProvider(id).