JsonHelper class abstract
Contract for models that can serialize to JSON maps.
Implement on DTOs, API response models, or form state objects that need to be encoded for storage or network transport.
class UserDto implements JsonHelper {
UserDto({required this.name, required this.email});
final String name;
final String email;
@override
Map<String, dynamic>? toJson() => {'name': name, 'email': email};
}
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> ? - Converts this object to a JSON-compatible map.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited