addRecognizerTemplates method Null safety

void addRecognizerTemplates(
  1. List<Template> templates,
  2. List<String> uuids
)

Implementation

void addRecognizerTemplates(List<Template> templates, List<String> uuids) {
  var exception = _getException();

  final addConstructor =
      _dll_handle.lookupFunction<_DynamicTemplateIndex_add_2_c, _DynamicTemplateIndex_add_2_dart>(_c_namespace + "DynamicTemplateIndex_add_2");

  Pointer<Pointer<Void>> tempTemplates = malloc.allocate(sizeOf<Pointer<Pointer<Void>>>() * templates.length);
  Pointer<Pointer<Utf8>> tempUuids = malloc.allocate(sizeOf<Pointer<Pointer<Utf8>>>() * uuids.length);

  for (int i = 0; i < templates.length; i++) {
    tempTemplates[i] = templates[i]._impl;
  }

  for (int i = 0; i < uuids.length; i++) {
    tempUuids[i] = uuids[i].toNativeUtf8();
  }

  addConstructor(_impl, tempTemplates, tempUuids, templates.length, exception);

  malloc.free(tempTemplates);
  malloc.free(tempUuids);

  checkException(exception, _dll_handle);
}