PrimaryKey class
Marks a field as the primary key of its
@Table.
Exactly one field per entity class must carry this annotation.
The column's SQL type is derived from the field's Dart type:
int->INTEGER PRIMARY KEY [AUTOINCREMENT]String->TEXT PRIMARY KEY(use for client-generated UUIDs; passautoIncrement: false)DateTime->TEXT PRIMARY KEY
The autoIncrement flag only applies to
int PKs (SQLite's AUTOINCREMENT is
restricted to INTEGER PRIMARY KEY). On a
non-int PK the value of autoIncrement
is ignored at DDL-generation time.
Constructors
- PrimaryKey({bool autoIncrement = true})
-
const
Properties
- autoIncrement → bool
-
Whether the PK should auto-increment. Only
meaningful for
intPKs; the codegen rejects this flag on non-intfields. Defaults totruebecause the most common case is an auto-incrementingintrow id.final - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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