Overview
TheApiary entity represents a bee yard or apiary in the Softbee beekeeping management system. It is the core domain entity that contains information about a beekeeper’s apiary location, including metadata such as name, location, beehive count, and treatment status.
Source: lib/feature/apiaries/domain/entities/apiary.dart
Class Definition
Properties
Unique identifier for the apiary. This is the primary key used to reference the apiary throughout the application.
The ID of the user who owns this apiary. Used for authorization and filtering apiaries by owner.
The display name of the apiary. This is the human-readable identifier that beekeepers use to distinguish between their different apiaries.
Optional geographical location or address of the apiary. This can be a street address, GPS coordinates, or any location description.
Optional count of beehives in this apiary. Helps beekeepers track the size of their operation.
Boolean flag indicating whether treatments are being applied to the beehives in this apiary. Important for tracking treatment protocols and compliance.
Optional timestamp indicating when the apiary was created in the system.
Methods
fromJson
Factory constructor that creates anApiary instance from a JSON map.
JSON map containing apiary data with the following structure:
id: Apiary identifier (converted to String)user_id: User identifiername: Apiary namelocation: Optional location stringbeehives_count: Optional beehive counttreatments: Boolean flag (defaults to false if not provided)created_at: Optional creation timestamp in GMT format
A new Apiary instance populated with data from the JSON map.
toJson
Converts the Apiary instance to a JSON map.JSON map representation of the apiary with snake_case keys matching the API format.
copyWith
Creates a copy of the Apiary with optionally updated fields.New ID value (rarely used as IDs are typically immutable)
New user ID value
New apiary name
New location
New beehive count
New treatments status
New creation timestamp
A new Apiary instance with the specified fields updated and all other fields copied from the original.
Usage Examples
Creating a new Apiary
Parsing from API response
Updating an apiary
Related
- Use Cases - Operations that can be performed on apiaries
- Repository - Data access layer for apiaries