standard_repositories 0.0.1-dev.3
standard_repositories: ^0.0.1-dev.3 copied to clipboard
A new standard for repositories in your Flutter applications.
Standard Repositories #
Provides an interface for Repositories in your Flutter apps.
If you've never heard of the concept of repositories, you can read about theme in the bloc documentation.
Usage #
Create a repository for a particular type
class StringRepository extends Repository<String> {
StringRepository(super.initialValue);
void makeUpperCase() {
value = value.toUpperCase();
}
}
Use the repository in your app
final repository = StringRepository('Hello, world!');
final subscription = repository.stream.listen((value) {
print(value);
});
repository.makeUpperCase();
subscription.cancel();
Prints
- Hello, world!
- HELLO, WORLD!
Available Repositories #
Repository #
A simple repository that allows you to manage a single value.
Setting Values:
value = value: Set the value to a new value.
Reading Values:
stream: A stream of the value.value: The current value.
MultiRepository #
A repository that allows you to manage a collection of values.
Setting Values:
value = values: Set the collection to a new value.add(value): Add a value to the collection.addAll(values): Add multiple values to the collection.
Reading Values:
stream: A stream of the collection.value: The current value of the collection.streamWhere(test): A stream of the values that match the test.singleWhere(test): The first value that matches the test.streamSingleWhere(test): A stream of the first value that matches the test.