setStatusBarColor function

Future<void> setStatusBarColor(
  1. Color statusBarColor, {
  2. Color? systemNavigationBarColor,
  3. Brightness? statusBarBrightness,
  4. Brightness? statusBarIconBrightness,
  5. int delayInMilliSeconds = 200,
})

Change status bar Color and Brightness

Implementation

Future<void> setStatusBarColor(
  Color statusBarColor, {
  Color? systemNavigationBarColor,
  Brightness? statusBarBrightness,
  Brightness? statusBarIconBrightness,
  int delayInMilliSeconds = 200,
}) async {
  await Future.delayed(Duration(milliseconds: delayInMilliSeconds));

  SystemChrome.setSystemUIOverlayStyle(
    SystemUiOverlayStyle(
      statusBarColor: statusBarColor,
      systemNavigationBarColor: systemNavigationBarColor,
      statusBarBrightness: statusBarBrightness,
      statusBarIconBrightness: statusBarIconBrightness ??
          (statusBarColor.isDark() ? Brightness.light : Brightness.dark),
    ),
  );
}