Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change 'Status Bar' colour in Flutter WEB? (After saving as a bookmark)

I can save my flutter web app on home screen as an bookmark icon. When I open it, the status bar color is black which looks very odd and does not appear to be an 'app like'.

How can I give the same color as my scaffold to the status bar?

My existing code is as follows:

...
@override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider<CP>(
      create: (BuildContext content) => CP(),
      child: MaterialApp(
          title: 'App title',
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            canvasColor: Colors.transparent,
            primarySwatch: white,
            //primaryColor: Colors.white
          ),
          routes: {
            ...
          },
          home: MainBody()),
    );
  }
}

class MainBody extends StatefulWidget {
  @override
  _MainBodyState createState() => _MainBodyState();
}

class _MainBodyState extends State<MainBody> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: Container(
              decoration: BoxDecoration(
                gradient: LinearGradient(
                  stops: [0.1, 1],
                  end: Alignment.bottomCenter,
                  begin: Alignment.topCenter,
                  colors: [
                    Provider.of<CP>(context).primary,
                    Provider.of<CP>(context).secondary,
                  ],
                ), //Provider.of<CP>(context).fMainPageGradient
              ),
              child: SafeArea(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: <Widget>[
                  ....

enter image description here

like image 690
Damandroid Avatar asked Oct 16 '25 11:10

Damandroid


1 Answers

Just add this line in index.html to the <head> tag and replace "#000000" with the color you like.

<meta name="theme-color" content="#000000">
like image 57
Franz Avatar answered Oct 19 '25 03:10

Franz