fromJson method

  1. @override
Offset fromJson(
  1. Map<String, dynamic> json
)

Converts a JSON map to an Offset object.

The JSON map must contain 'x' and 'y' keys with numeric values. Both integer and double values are supported and will be converted to doubles.

Example:

final converter = OffsetConverter();
final offset = converter.fromJson({'x': 10, 'y': 20});
// offset.dx == 10.0, offset.dy == 20.0

Implementation

@override
Offset fromJson(Map<String, dynamic> json) {
  return Offset((json['x'] as num).toDouble(), (json['y'] as num).toDouble());
}