readMap method

BridgeModel readMap(
  1. String mapName,
  2. dynamic fieldKey,
  3. dynamic initial
)

reads a Map from Memory

Implementation

BridgeModel readMap(String mapName, dynamic fieldKey, dynamic initial) {
  Map cache = read(mapName, {}).slice;

  ///first checks if the provided key is already in memory
  if (cache.containsKey(fieldKey)) {
    //returns bridgemodel if key exists and there is no type conflict
    return BridgeModel(cache[fieldKey], cache[fieldKey].runtimeType);
  }
  //and if not it takes the type of the initial value
  else {
    //returns bridgemodel with initial and type
    return BridgeModel(initial, initial.runtimeType);
  }
}