Entity class

An entity is a uniquely identifiable object that serves as a container or identifier for components in a Dependency Injection (DI) or Entity-Component-System (ECS) framework.

Constructors

Entity.new(int id)
Creates a new instance of Entity identified by id. The id must be 0 or greater.
const
Entity.obj(Object object)
Creates a new instance of Entity from the specified object. This effectively uses objId to convert the object to an int and then uses that as the id for the new Entity instance.
factory
Entity.reserved(int id)
Creates a new Entity with the given id. The id must be less than 0.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
id int
The value associated with this Entity instance.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

isDefault() bool
isNotDefault() bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preferOverDefault(Entity other) Entity
Returns other if this is DefaultEntity, otherwise returns this.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

objId(Object object) int
Creates an integer id from the specified object. If the object is already an int, it is returned as is. Otherwise, the object is converted to a string with spaces removed, then the hashCode is calculated and returned.