Entity class

Annotation for create table in database. You can set tableName and indices for this table, in this annotation. If you don't set tableName, the class name will be set as the default name. You have to set primary key for table using PrimaryKey annotation. The entity must have exactly one primary key and only integer primary key can be auto increment. All properties of the class that this annotation applied on, map to a column in the table unless properties that Ignore annotation are applied on. Default column name is property name. If you want to change it use Column annotation and set name property.

@Entity(tableName: 'notes', indices: [
  Index(columns: ['text'], unique: true)
])
class Note {
  @PrimaryKey(autoGenerate: true)
  final int? id;

  final String text;
  final bool isEdited;
  final DateTime createDate;
  final DateTime? updateDate;

  @Column(name: 'lat')
  final double? latitude;

  @Column(name: 'lng')
  final double? longitude;

  @Ignore()
  final String? ignoreTest;

  Note({
    this.id,
    required this.text,
    required this.isEdited,
    required this.createDate,
    this.updateDate,
    this.latitude,
    this.longitude,
    this.ignoreTest,
  });
}

Constructors

Entity({String? tableName, List<Index>? indices})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
indices List<Index>?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tableName 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

Static Properties

fields ↔ _EntityFields
getter/setter pair