setDataBase method Null safety

Future<void> setDataBase(
  1. List<DataBaseElement> dataBase,
  2. {SearchAccelerationType acceleration = SearchAccelerationType.SEARCH_ACCELERATION_1}
)

Implementation

Future<void> setDataBase(List<DataBaseElement> dataBase,
    {SearchAccelerationType acceleration = SearchAccelerationType.SEARCH_ACCELERATION_1}) async {
  ReceivePort receivePort = ReceivePort();
  List<Map<String, dynamic>> data = [];

  dataBase.forEach((element) {
    Map<String, dynamic> elementData = Map<String, dynamic>();

    elementData["person_id"] = element.person_id;
    elementData["element_id"] = element.element_id;
    elementData["distance_threshold"] = element.distance_threshold;
    elementData["face_template"] = element.face_template._impl.address;

    data.add(elementData);
  });

  _sendPort.send({
    "event": _VideoWorkerEvents.SET_DATA_BASE,
    "sendPort": receivePort.sendPort,
    "data": data,
    "acceleration": acceleration
  });

  dynamic isolateResult = await receivePort.first;

  _checkException(isolateResult);

  return isolateResult;
}