OffsetConverter class

A JSON converter for Flutter's Offset class.

This converter serializes Offset objects to JSON as a map with 'x' and 'y' keys, and deserializes JSON maps back to Offset objects.

Example JSON representation:

{
  "x": 100.0,
  "y": 200.0
}

Usage with json_serializable:

@JsonSerializable()
class MyClass {
  @OffsetConverter()
  final Offset position;

  MyClass(this.position);
}

See also:

Constructors

OffsetConverter()
Creates a const instance of OffsetConverter.
const

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

fromJson(Map<String, dynamic> json) Offset
Converts a JSON map to an Offset object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson(Offset offset) Map<String, dynamic>
Converts an Offset object to a JSON map.
toString() String
A string representation of this object.
inherited

Operators

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