autoChangeSystemUi method

void autoChangeSystemUi({
  1. required ThemeMode theme_mode,
  2. required Brightness onChangeBrightness(),
})

Implementation

void autoChangeSystemUi({
  required ThemeMode theme_mode,
  required Brightness Function() onChangeBrightness,
}) {
  if (theme_mode == ThemeMode.dark) {
    SystemChrome.setSystemUIOverlayStyle(
      const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarIconBrightness: Brightness.light,
        statusBarBrightness: Brightness.dark,
      ),
    );
  } else if (theme_mode == ThemeMode.light) {
    SystemChrome.setSystemUIOverlayStyle(
      const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarIconBrightness: Brightness.dark,
        statusBarBrightness: Brightness.light,
      ),
    );
  } else if (theme_mode == ThemeMode.system) {
    Brightness brightness = onChangeBrightness();
    // brightness ;
    SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarIconBrightness: (brightness == Brightness.light) ? Brightness.dark : Brightness.light,
        statusBarBrightness: (brightness == Brightness.light) ? Brightness.light : Brightness.dark,
      ),
    );
  }

  notifyListeners();
}