DarkstormBackend constructor

DarkstormBackend({
  1. required Uri baseUrl,
  2. required String apiKey,
  3. Uri? internetCheckAddress,
  4. bool waitForInternet = true,
  5. void onError(
    1. Object,
    2. StackTrace
    )?,
})

Implementation

DarkstormBackend(
    {required this.baseUrl,
    required this.apiKey,
    Uri? internetCheckAddress,
    this.waitForInternet = true,
    this.onError})
    : con = InternetConnection.createInstance(
          customCheckOptions: internetCheckAddress != null
              ? [InternetCheckOption(uri: internetCheckAddress)]
              : null,
          useDefaultOptions: internetCheckAddress == null) {
  platform.when(
      io: () => platform.when(
            fuchsia: () => plat = "fuchsia",
            windows: () => plat = 'windows',
            android: () => plat = 'android',
            iOS: () => plat = 'iOS',
            macOS: () => plat = 'macOS',
            linux: () => plat = 'linux',
            unknown: () => plat = 'unknown',
          ),
      web: () => plat = "web",
      unknown: () => plat = "unknown");
  con.internetStatus.then(
      (value) => _internetAvailable = value == InternetStatus.connected);
  con.onStatusChange.listen(
      (event) => _internetAvailable = event == InternetStatus.connected);
}