initPlatformState method

Future<void> initPlatformState()

Implementation

@pragma("vm:entry-point")
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
  // Load persisted fetch events from SharedPreferences

  // Configure BackgroundFetch.
  try {
    var status = await BackgroundFetch.configure(
        BackgroundFetchConfig(
            minimumFetchInterval: 1,
            forceAlarmManager: true,
            stopOnTerminate: false,
            startOnBoot: true,
            enableHeadless: true,
            requiresBatteryNotLow: false,
            requiresCharging: false,
            requiresStorageNotLow: false,
            requiresDeviceIdle: false,
            requiredNetworkType: NetworkType.NONE),
        _onBackgroundFetch,
        _onBackgroundFetchTimeout);
    print('[BackgroundFetch] configure success: $status');

    // task on init

    String cdate =
        DateFormat("EEEEE yyyy-MM-dd HH:mm:ss").format(DateTime.now());
    print("[BackgroundFetch] $cdate ");
    todo();
  } on Exception catch (e) {
    print("[BackgroundFetch] configure ERROR: $e");
  }

  // If the widget was removed from the tree while the asynchronous platform
  // message was in flight, we want to discard the reply rather than calling
  // setState to update our non-existent appearance.
  // if (!mounted) return;
}