createIndex method Null safety

TemplateIndex createIndex(
  1. List<Template> templates,
  2. int search_threads_count,
  3. int reserve_queries_count
)

Create the TemplatesIndex for quick search.
The total size of all indexes is limited by the license.
templates - Vector of templates for creating an index.
search_threads_count - Count of threads that will be used while searching in this index.
reserve_queries_count - Integer passed to TemplatesIndex::reserveSearchMemory, which is called with the created index.
return - Created index.

Implementation

TemplateIndex createIndex(List<Template> templates, int search_threads_count, int reserve_queries_count) {
  var exception = _getException();
  final _createIndex = _dll_handle.lookupFunction<_Recognizer_create_index_c, _Recognizer_create_index_dart>(_c_namespace + 'Recognizer_createIndex');

  Pointer<Pointer<Void>> templatesImpl = malloc.allocate(sizeOf<Pointer<Pointer<Void>>>() * templates.length);
  for (var i = 0; i < templates.length; i++) {
    templatesImpl[i] = templates[i]._impl;
  }

  final templIndexPointer = _createIndex(_impl, templates.length, templatesImpl, search_threads_count, exception);
  checkException(exception, _dll_handle);

  malloc.free(templatesImpl);
  return TemplateIndex(_dll_handle, templIndexPointer);
}