repo_scaffold

Last updated:

0 purchases

repo_scaffold Image
repo_scaffold Images
Add to Cart

Description:

repo scaffold

Repo Scaffold #
This project aims to give a simple interface to create repositories that can be used with n number of queries and mutations
How to use #
Create your first first repo
class ExampleRepo extends Repo {
final List<int> numbers;
}
copied to clipboard
Query #
Create a query
class ListAllNumbersQuery implements RepoQuery<Future<List<int>>> {
@override
Future<List<int>> query(ExampleRepo repo) async {
return repo.numbers;
}
}
copied to clipboard
Use query
final numbers = await ExampleRepo.query(
ListAllNumbersQuery(),
);
copied to clipboard
Mutation #
Create mutation
class AddItemMutation implements RepoMutation<Future<void>> {
final int item;

AddItemMutation({
required this.item,
});

@override
Future<void> mutate(ExampleRepo repo) async {
repo.numbers.add(item);
}
}
copied to clipboard
Use mutation
await ExampleRepo.mutate(
AddItemMutation(
item: 5,
),
);
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.