isAssignableWith method Null safety

bool isAssignableWith(
  1. dynamic dartValue
)

Whether dartValue can be assigned to properties with this type.

Implementation

bool isAssignableWith(dynamic dartValue) {
  if (dartValue == null) {
    return true;
  }

  switch (kind) {
    case ManagedPropertyType.bigInteger:
      return dartValue is int;
    case ManagedPropertyType.integer:
      return dartValue is int;
    case ManagedPropertyType.boolean:
      return dartValue is bool;
    case ManagedPropertyType.datetime:
      return dartValue is DateTime;
    case ManagedPropertyType.doublePrecision:
      return dartValue is double;
    case ManagedPropertyType.map:
      return dartValue is Map<String, dynamic>;
    case ManagedPropertyType.list:
      return dartValue is List<dynamic>;
    case ManagedPropertyType.document:
      return dartValue is Document;
    case ManagedPropertyType.string:
      {
        if (enumerationMap != null) {
          return enumerationMap!.values.contains(dartValue);
        }
        return dartValue is String;
      }
    default:
      return false;
  }
}