fromNative method

  1. @override
DogGraphValue fromNative(
  1. dynamic value
)
inherited

Converts a native value to a DogGraphValue.

Implementation

@override
DogGraphValue fromNative(value) {
  if (value == null) return DogNull();
  if (value is String) return DogString(value);
  if (value is int) return DogInt(value);
  if (value is double) return DogDouble(value);
  if (value is bool) return DogBool(value);
  if (value is Iterable) {
    return DogList(value.map((e) => fromNative(e)).toList());
  }
  if (value is Map) {
    return DogMap(value
        .map((key, value) => MapEntry(fromNative(key), fromNative(value))));
  }

  throw ArgumentError.value(
      value, null, "Can't coerce native value to dart object graph");
}