ensureInitialized static method

Future<void> ensureInitialized({
  1. YaruWindowState? state,
  2. @visibleForTesting Map<String, String>? environment,
})

Initializes the window for testing. A specific state can be overridden and it is safe to close the window without actually closing it.

Implementation

static Future<void> ensureInitialized({
  YaruWindowState? state,
  @visibleForTesting Map<String, String>? environment,
}) async {
  _state = state;
  if (!(environment ?? Platform.environment).containsKey('FLUTTER_TEST')) {
    _platform ??= YaruWindowPlatform.instance;
  }
  if (YaruWindowPlatform.instance is! YaruTestWindow) {
    YaruWindowPlatform.instance = YaruTestWindow();
  }
}