fromJson method

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

Converts a JSON map to a Size object.

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

Example:

final converter = SizeConverter();
final size = converter.fromJson({'width': 100, 'height': 50});
// size.width == 100.0, size.height == 50.0

Implementation

@override
Size fromJson(Map<String, dynamic> json) {
  return Size(
    (json['width'] as num).toDouble(),
    (json['height'] as num).toDouble(),
  );
}