A Swift-inspired persistent data management solution for Flutter. Provides simple, powerful, and type-safe way to persist your app's models with automatic UI updates.
Package selection guidance compiled from public package information, community data, and project usage.
Cozy Data is a Flutter package inspired by Swift's data management approach, offering a type-safe and intuitive way to persist app models using SQL. It automatically handles database operations and triggers UI updates when data changes, reducing boilerplate and improving development speed. Designed for simplicity and reliability, it integrates seamlessly with Flutter’s reactive framework, making it ideal for apps requiring persistent storage with real-time UI synchronization.
Use cases
Offline-first mobile applications
Real-time data synchronization
Type-safe model persistence
Dynamic form and list state management
App settings and user preferences storage
Key features
Automatic UI updates on data change
Type-safe data modeling
Swift-inspired syntax and design
Built-in CRUD operations
Seamless integration with Flutter widgets
Suitable for
Flutter developers seeking simple persistence
Apps needing offline capabilities
Teams prioritizing code safety and maintainability
Projects with frequent data model changes
Developers familiar with Swift or similar declarative patterns
Considerations
Limited to SQL-based storage
Requires understanding of basic database concepts
May introduce overhead for very simple use cases
Not suitable for non-structured or large-scale NoSQL needs
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
A Swift-inspired persistent data management solution for Flutter. CozyData provides a simple, powerful, and type-safe way to persist your app's models and automatically update your UI when data changes.
final recipe = awaitCozyData.fetcById<Recipe>(persistentModelID: id);
Advanced Usage
The CozyQueryBuilder is a class used to construct complex SQL-like queries in a structured and programmatic way. It allows you to specify various components of a query, such as fields to group by, order by, having clauses, joins, limits, offsets, selected fields, subqueries, table aliases, and where conditions.
final customBuilder = CozyQueryBuilder(
// groupByFields: A list of fields by which the results should be grouped. In this case, it's an empty list, meaning no grouping is applied.
groupByFields: [],
// orderByFields: A list of fields by which the results should be ordered. It's also an empty list here, so no specific ordering is applied.
orderByFields: [],
// Conditions that filter the groups created by the groupBy clause. It's empty, indicating no such conditions.
havingClauses: [],
// joins: A list of join operations to combine rows from two or more tables based on a related column. No joins are specified here
joins: [],
// limit: The maximum number of records to return. Here, it's set to 10.
limit: 10,
// offset: The number of records to skip before starting to return records. It's set to 0, meaning no records are skipped.
offset: 0,
// selectFields: A list of fields to be selected in the query. It's empty, meaning all fields are selected
selectFields: [],
// subqueries: A list of subqueries to be included in the main query. It's empty, indicating no subqueries.
subqueries: [],
// tableAliases: A map of table aliases to be used in the query. It's an empty map here.
tableAliases: {},
// whereGroups: A list of conditions to filter the results. It's empty, meaning no filtering conditions are applied.
whereGroups: [],
);
Sorting and Filtering once
final recipes = awaitCozyData.fetch<Recipe>(customBuilder: customBuilder);
The CozyQueryController manages query operations for a CozyQueryListener. It allows adding where conditions, joins, order by fields, and custom queries to the listener.