2

I try to change the status bar in the safari browser, I search it and it was a lot's question about it but none of them fixed my issue. I tried change-status-bar-color and how-to-change-chrome-header-color.

enter image description here

This blue area is around iPhone's notches, and I want to change the color in the whole app.

thanks for your attention.

Ali Azimoshan
  • 652
  • 7
  • 21

2 Answers2

4

You want to change the value for theme-color. The default color you're seeing is defined in your web/manifest.json file.

You could also set it, for example to white for your light-theme and to black for your dark-theme, by adding following lines to your web/index.html:

<meta name="theme-color" media="(prefers-color-scheme: light)" content="#FFFFFF">
<meta name="theme-color" media="(prefers-color-scheme: dark)"  content="#000000">

You could also change it dynamically via dart:js by adding a script to your web/index.html:

<script>
  function setMetaThemeColor(color) {
      document.querySelector('meta[name="theme-color"]').setAttribute("content", color);
    }
</script>

Then call it via dart:js:

import 'package:flutter/material.dart';
import 'dart:js' as js;

extension ColorString on Color {
  String toHexString() {
    return '#${(value & 0xFFFFFF).toRadixString(16).padLeft(6, '0').toUpperCase()}';
  }
}

void setMetaThemeColor(Color color) {
  js.context.callMethod("setMetaThemeColor", [color.toHexString()]);
}
Markus Rubey
  • 4,988
  • 2
  • 20
  • 16
  • 1
    should be accepted. manifest.json didn't work for me (don't know why) but index.html config worked perfectly. Don't forget to clear safari cache or use private navigation to see changes quickly – nicover Mar 31 '22 at 15:27
  • Thanks this works. Any idea if it is possible to put this on Dart code instead? – Roddy R Jun 03 '22 at 01:32
0

Please try to use the below code:

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
  statusBarColor: Colors.red,
));
BambinoUA
  • 4,295
  • 3
  • 28
  • 39
Gbenga B Ayannuga
  • 1,289
  • 1
  • 7
  • 22