main function

void main()

Implementation

void main() async {
  // This is the main entry point for the app. The [async] is required because
  // we asynchronously [await] the window manager below. Often, `main()` will
  // simply include just [runApp].

  if (isDesktop(PlatformWrapper())) {
    // Suport [windowManager] options for the desktop. We do this here before
    // running the app. If there is no [windowManager] options we probably don't
    // need this whole section.

    // Ensure things are set up properly since we haven't yet initialised the
    // app with [runApp].

    WidgetsFlutterBinding.ensureInitialized();
    await windowManager.ensureInitialized();

    const windowOptions = WindowOptions(
      // We can set various desktop window options here.

      // Setting [alwaysOnTop] here will ensure the app starts on top of other
      // apps on the desktop so that it is visible (otherwise, Ubuuntu with
      // GNOME it is often lost below other windows on startup which can be a
      // little disconcerting). We later turn it off as we don't want to force
      // it always on top.

      alwaysOnTop: true,

      // The [title] is used for the window manager's window title.

      title: 'HealthPod - Private Solid Pod for Health Data',
    );

    // Once the window manager is ready we reconfigure it a little.

    await windowManager.waitUntilReadyToShow(windowOptions, () async {
      await windowManager.show();
      await windowManager.focus();
      await windowManager.setAlwaysOnTop(false);
    });
  }

  // Ready to run the app.

  runApp(const HealthPod());
}