toDoubleListJson static method

List<double>? toDoubleListJson(
  1. dynamic json
)

Converts JSON to a list of doubles.

Implementation

static List<double>? toDoubleListJson(dynamic json) {
  if (json == null) return null;
  if (json is List<double>) return json;
  if (json is List<dynamic>) return json.map(toDoubleJson).whereType<double>().toList();
  if (json is String) {
    return json
        .split(',')
        .map((String s) => double.tryParse(s.trim()))
        .whereType<double>()
        .toList();
  }
  return null;
}