fromJson method

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

Implementation

@override
Radius? fromJson(Map<String, dynamic>? json) {
  if (json == null) return null;

  String? type = json['type'];

  switch (type) {
    case 'circular':
      return Radius.circular((json['radius'] as num).toDouble());

    case 'elliptical':
      return Radius.elliptical(
        ((json['x'] ?? 0) as num).toDouble(),
        ((json['y'] ?? 0) as num).toDouble(),
      );

    case 'zero':
      return Radius.zero;
  }

  throw 'Unsuported_Json_Value';
}