Id class

Id annotation for marking a single field as the primary key.

Use this annotation on a single field to designate it as the primary key. For composite primary keys (multiple columns), use @PrimaryKey on the class instead.

Note: You cannot use both @Id and @PrimaryKey in the same entity. A build error will be thrown if both are used together.

Example:

@Entity(tableName: 'users')
class UserEntity {
  @Id()
  int id;
  String name;
}

Constructors

Id({bool autoIncrement = true, String? strategy = 'AUTOINCREMENT'})
const
Id.mysql({bool autoIncrement = true, String? strategy = 'AUTO_INCREMENT'})
const
Id.postgres({bool autoIncrement = true, String? strategy = 'SERIAL'})
const
Id.sqlite({bool autoIncrement = true, String? strategy = 'AUTOINCREMENT'})
const

Properties

autoIncrement bool
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
strategy String?
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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