didChangePlatformBrightness method

  1. @override
void didChangePlatformBrightness()
override

主题模式变化回调 当系统的主题模式(亮/暗模式)发生变化时调用。

Called when the system theme mode changes (light/dark mode).

Implementation

@override
void didChangePlatformBrightness() {
  super.didChangePlatformBrightness();

  var widgetsBinding = WidgetsBinding.instance;
  final brightness = widgetsBinding.platformDispatcher.platformBrightness;
  final themeMode = (brightness == Brightness.light ? 'Light' : 'Dark');
  loge("Theme mode changed to $themeMode");
}