DatabaseItem class Null safety

A class representing a single item to store using DatabaseStorage

Schema specified in the constructor is represented on the object as a readonly map. The keys will represent the column names and the case insensitive string values represent the type of data to be stored in that column. Notes:

  • id can be excluded, it will automatically be set to STRING PRIMARY KEY
  • adjusting this map will adjust the table schema by adding columns not currently in the database
  • columns removed from the item schema will remain in the database
class Dog extends DatabaseItem {
  final String id;
  final String name;
  final int age;

  Dog(this.id, this.name, this.age): super(id, columns: {
    "name": "TEXT",
    "age": "integer"
  });
...
}
Implemented types

Constructors

DatabaseItem(String id, {required Map<String, String> schema})

Properties

columns List<String>
Column names for a database row for this item
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
id String
The primary identifier
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
schema Map<String, String>
Column names to datatype for a database row for this item
read-only
tableName → dynamic
The name of the table to store this item in
read-only

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toMap() Map<String, Object?>
Generates a map representing the data in the item. The keys must correspond to the names of the columns in the database.
toString() String
A string representation of this object. [...]
inherited

Operators

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

Static Properties

schemaVerified bool
Has the schema been verified with that in the database
read / write