initialize method Null safety

void initialize(
  1. {LogLevel? logLevel,
  2. LoggingBackend? loggingBackend,
  3. String? libsndfilePath}
)

Initialise the library.

Implementation

void initialize(
    {LogLevel? logLevel,
    LoggingBackend? loggingBackend,
    String? libsndfilePath}) {
  final config = calloc<syz_LibraryConfig>();
  synthizer.syz_libraryConfigSetDefaults(config);
  if (logLevel != null) {
    config.ref.log_level = logLevel.toInt();
  }
  if (loggingBackend != null) {
    config.ref.logging_backend = loggingBackend.toInt();
  }
  Pointer<Int8>? libSndFilePointer;
  if (libsndfilePath != null) {
    libSndFilePointer = libsndfilePath.toNativeUtf8().cast<Int8>();
    config.ref.libsndfile_path = libSndFilePointer;
  }
  check(synthizer.syz_initializeWithConfig(config));
  if (libSndFilePointer != null) {
    malloc.free(libSndFilePointer);
  }
  calloc.free(config);
  _wasInit = true;
}