PrimaryKey class

Annotation for define primary key for your entity(table). Defining a field with this annotation is necessary. Also an entity must have exactly one primary key. In other words, your entity must have exactly one field with this annotation. If your primary key variable type be int, you can set autoGenerate property to true. If autoGenerate property is set to true, the field type must be nullable and don't pass this field in object creation.

@Entity()
class Note {
  @PrimaryKey(autoGenerate: true)
  final int? id;

  final String text;
  final bool isEdited;

  Note({
    this.id,
    required this.text,
    required this.isEdited,
  });
}

Constructors

PrimaryKey({String? name, bool autoGenerate = false})
const

Properties

autoGenerate bool
final
hashCode int
The hash code for this object.
no setterinherited
name String?
final
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

Static Properties

fields ↔ _PrimaryKeyFields
getter/setter pair