TetherModel<T>.fromSqlite constructor

TetherModel<T>.fromSqlite(
  1. Row sqliteData
)

A generic factory constructor to create a TetherModel instance from an SQLite Row.

Note: Similar to TetherModel.fromJson, this default factory returns a _GenericTetherModel. For type-safe deserialization from SQLite into specific model types, each subclass must provide its own static YourModelType fromSqlite(Row sqliteData) factory.

It is strongly recommended to use the specific fromSqlite factories in your application code: YourModel.fromSqlite(row).

Implementation

factory TetherModel.fromSqlite(Row sqliteData) {
  // The Row object from sqlite_async is already a Map<String, dynamic> like structure.
  // However, to be explicit and ensure we have a standard Map, we can create one from it.
  // If Row itself can be directly used as Map<String, dynamic> in all contexts,
  // this conversion might be simplified, but creating a new map is safer.
  final Map<String, dynamic> mapData = Map<String, dynamic>.from(sqliteData);
  return _GenericTetherModel(mapData) as TetherModel<T>;
}