AttributeCaster<T> class
abstract
Base class for custom attribute casters
Custom casters allow you to define how attributes are converted between database representation and model properties.
Example:
class UserPreferencesCaster extends AttributeCaster<UserPreferences> {
@override
UserPreferences? get(dynamic value) {
if (value == null) return null;
return UserPreferences.fromJson(jsonDecode(value));
}
@override
dynamic set(UserPreferences? value) {
if (value == null) return null;
return jsonEncode(value.toJson());
}
}
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
get(
dynamic value) → T? - Convert database value to model property value
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
T? value) → dynamic - Convert model property value to database value
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited