setWindowRoundedCorners method

void setWindowRoundedCorners({
  1. bool rounded = true,
  2. bool small = false,
})

Sets this Window rounded corners attributes.

  • If rounded is true will set this Window with rounded corners, otherwise will disable the rounded corners.
  • If small is true round the corners with a small radius.

Implementation

void setWindowRoundedCorners({bool rounded = true, bool small = false}) {
  final pref = calloc<DWORD>();
  try {
    final hwnd = this.hwnd;

    pref.value = rounded
        ? (small ? DWMWCP_ROUNDSMALL : DWMWCP_ROUND)
        : DWMWCP_DONOTROUND;

    DwmSetWindowAttribute(
      hwnd,
      DWMWA_WINDOW_CORNER_PREFERENCE,
      pref,
      sizeOf<DWORD>(),
    );
  } on WindowsException catch (e) {
    // Not supported before Windows 11:
    _logWindow.warning("Can't set window rounded corners: $e");
  } finally {
    free(pref);
  }
}