This data_inmemory package provides a lightweight, non-persistent in-memory implementation of the DataClient interface within the Flutter News App Full Source Code Toolkit. It is designed primarily for testing, local development, or scenarios where a temporary data store is sufficient. This package allows for simulating a backend data source entirely in memory, supporting standard CRUD operations, advanced querying, and aggregation capabilities without requiring a live database connection.
This package offers a comprehensive set of features for managing data entities in memory.
🧱 Core Functionality
DataInMemoryClient<T>Class: A concrete in-memory implementation of theDataClient<T>interface, enabling type-safe interactions with various data models.- Flexible Initialization: Supports
initialDatato pre-populate the client with existing data, accelerating setup for testing and development.
- CRUD Operations: Implements
create,read,update, anddeletemethods for standard data manipulation. - User-Scoped & Global Data: Supports operations tied to a specific
userIdfor user-scoped data, as well as operations targeting global data not associated with any user. - Rich Document-Style Querying: The
readAllmethod supports advanced filtering with operators like$in,$nin,$ne,$gteon any field (including nested ones), multi-field sorting viaSortOptionobjects, and cursor-based pagination viaPaginationOptions. - Generic Text Search: Supports the
$regexoperator for powerful, case-insensitive text searches on any string field (e.g.,{'name': {'$regex': 'term', '$options': 'i'}}). - Efficient Counting & Aggregation: Includes a
countmethod for efficient document counting and anaggregatemethod to simulate basic MongoDB aggregation pipelines (supporting$match,$group,$sort,$limit), enabling testing of analytics-style queries.
HttpExceptionPropagation: Throws standard exceptions frompackage:core(e.g.,NotFoundException,BadRequestException) for consistent error handling, ensuring predictable error management across the application layers.
💡 Your Advantage: You get a meticulously designed, production-quality in-memory data client that simplifies testing, accelerates local development, and provides robust data management capabilities without the overhead of a persistent backend. This package is ideal for rapid prototyping and reliable unit/integration testing.
This source code is licensed for commercial use and is provided for local evaluation. A Lifetime Commercial License is required for any production or public-facing application.
Please visit the main Flutter News App Full Source Code Toolkit organization page to review the full license terms and to purchase.