fromMap<Type, InnerTypeSerialized> static method

SearchResult<Type> fromMap<Type, InnerTypeSerialized>(
  1. Map<String, dynamic> map,
  2. Type typeDeserializeConstructor(
    1. InnerTypeSerialized
    )
)

Implementation

static SearchResult<Type> fromMap<Type, InnerTypeSerialized>(Map<String,dynamic> map, Type Function(InnerTypeSerialized) typeDeserializeConstructor){
  if(map['numFetched'] != null && map['numFetched'] is int
     && map['numTotalSearched'] != null && map['numTotalSearched'] is int
     && map['collection'] != null && (map['collection'] is List<InnerTypeSerialized> || map['collection'] is List<Type>)
  ){
    if(map['collection'] is List<InnerTypeSerialized>){
      List<Type> t = List.empty(growable: true);
      for(InnerTypeSerialized i in (map['collection'] as List<InnerTypeSerialized>)){
        t.add(typeDeserializeConstructor(i));
      }
      return SearchResult(map['numFetched'], map['numTotalSearched'], t);
    }else{
      return SearchResult(map['numFetched'], map['numTotalSearched'], map['collection']);
    }
  }else{
    throw InteractivePlusSystemException.SERIALIZATION_EXCEPTION;
  }
}