Drop
The Drop Module in the Flood toolkit aims to provide a consistent way to model data, query and update it, and be flexible to change the data source depending on the current environment. It offers a set of tools and components that simplify the process of defining, storing, querying, and updating data entities, making it easier to build robust and scalable applications.
Key Concepts
Drop introduces several key concepts that work together to provide a comprehensive data management solution:
-
ValueObjects: Define the structure and format of your data, including validation rules and constraints.
-
Entities: Represent the fundamental units of data storage, encapsulating ValueObjects with a unique identifier.
-
Repositories: Determine where and how Entities are stored, with flexible options for different environments.
-
Queries: Provide a powerful mechanism to retrieve and filter data from repositories.
-
Security: Offer granular control over data access and operations.
-
Auto-generated UI: Integrate with the Port Module to automatically generate user interfaces based on your data models.
-
Hooks: Simplify data retrieval and binding in Flutter widgets, with automatic updates when data changes.
Implementations
Drop supports various repository implementations, including file-based storage, cloud-based storage, and environment-specific storage. However, the .cloud
modifier on its own does not provide any implementation details. It requires repositoryImplementations
to be passed into FloodCoreComponent
to specify the exact implementation of the repositories to use in those environments.
For example, if you pass in FirebaseCloudRepositoryImplementation
as one of the repositoryImplementations
, it will make any .cloud
repositories (or any .adapting
repositories in a cloud environment) use the Firebase implementation. Similarly, you can provide implementations for other environments or storage mechanisms.
Here's an example of passing repository implementations to FloodCoreComponent
:
await corePondContext.register(FloodCoreComponent(
repositoryImplementations: (corePondConext) => [
FirebaseCloudRepositoryImplementation(),
],
));
By providing the appropriate repository implementations, you can easily switch between different storage mechanisms based on the environment or your application's requirements.
Use with Pond
To use Drop with Flood:
- Add the
FloodCoreComponent
to yourCorePondContext
andFloodAppComponent
to yourAppPondContext
:
await corePondContext.register(FloodCoreComponent(
repositoryImplementations: [
...
],
));
await appPondContext.register(FloodAppComponent());
- Register your Repositories to the
CorePondContext
so that Flood knows where to find your data from your queries:
await corePondContext.register(UserRepository());
By following these steps, Drop will be automatically added to your project, and you can start leveraging its features for data management and querying.
Debugging
Use the Debug Module to inspect your drop repositories and view the queries that were used to build a page.