setHighRefreshRate static method Null safety

Future<void> setHighRefreshRate()

setHighRefreshRate changes preferred mode to highest refresh rate available maintaining current resolution

Implementation

static Future<void> setHighRefreshRate() async {
  final List<DisplayMode> modes = await supported;
  final DisplayMode activeMode = await active;

  DisplayMode newMode = activeMode;
  for (final DisplayMode mode in modes) {
    if (mode.height == newMode.height &&
        mode.width == newMode.width &&
        mode.refreshRate > newMode.refreshRate) {
      newMode = mode;
    }
  }

  await setPreferredMode(newMode);
}