TetherModel<T>.fromJson constructor
A generic factory constructor to create a TetherModel
instance from a JSON map.
Note: This default factory returns a _GenericTetherModel
which provides
basic pass-through serialization. For type-safe deserialization into specific
model types (e.g., User
, Product
), each subclass must provide its own
static YourModelType fromJson(Map<String, dynamic> json)
factory.
This generic factory is primarily a placeholder or for internal use where
the specific type T
is not critical at the point of creation but is expected
to be cast or handled by a more specific mechanism later.
It is strongly recommended to use the specific fromJson
factories
in your application code: YourModel.fromJson(json)
.
Implementation
factory TetherModel.fromJson(Map<String, dynamic> json) {
// This acts as a fallback or a way to handle dynamic model creation
// if the concrete type isn't known at compile time for the factory call.
// However, direct use of subclass-specific fromJson is preferred.
return _GenericTetherModel(json) as TetherModel<T>;
}