initialize static method

void initialize()

Implementation

static void initialize() {
  logging.hierarchicalLoggingEnabled = true;
  log.onRecord.listen((e) {
    developer.log(
      e.message,
      time: e.time,
      sequenceNumber: e.sequenceNumber,
      level: e.level.value,
      name: e.loggerName,
      zone: e.zone,
      error: e.error,
      stackTrace: e.stackTrace,
    );
  });

  String fileName;
  if (Platform.isWindows) {
    fileName = 'libdivecomputer-0.dll';
  } else if (Platform.isAndroid) {
    fileName = 'libdivecomputer.so';
  } else if (Platform.isMacOS) {
    fileName = 'libdivecomputer.0.dylib';
  } else {
    throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
  }

  log.config('Loading native library');
  _library = ffi.DynamicLibrary.open(fileName);
  _bindings = DiveComputerFfiBindings(_library);
  log.fine('Loading complete');
}