setEffect static method
Future<void>
setEffect({
- required WindowEffect effect,
- Color color = Colors.transparent,
- bool dark = true,
Sets specified effect for the window.
When using WindowEffect.mica, dark
argument can be used to switch
between light or dark mode of Mica.
When using WindowEffect.acrylic, WindowEffect.aero,
WindowEffect.disabled, WindowEffect.solid or
WindowEffect.transparent,
color
argument can be used to change the resulting tint (or color) of
the window background.
Examples
await Window.setEffect(
effect: WindowEffect.acrylic,
color: Color(0xCC222222),
);
await Window.setEffect(
effect: WindowEffect.mica,
dark: true,
);
Implementation
static Future<void> setEffect({
required WindowEffect effect,
Color color = Colors.transparent,
bool dark = true,
}) async {
if (Platform.isMacOS) {
final material =
WindowEffectToMaterialConverter.convertWindowEffectToMaterial(effect);
WindowManipulator.setMaterial(material);
return;
}
await _kCompleter.future;
await _kChannel.invokeMethod(
_kSetEffect,
{
'effect': effect.index,
'color': {
'R': color.red,
'G': color.green,
'B': color.blue,
'A': color.alpha,
},
'dark': dark,
},
);
}