Ndiaga GUEYE
Ndiaga GUEYE

Reputation: 391

Flutter - Change status bar color whithout AppBar

How to change status bar color whithout AppBar ?

my snippet code :

 @override
  Widget build(BuildContext context) {

    return Scaffold(
      body: AnnotatedRegion<SystemUiOverlayStyle>(
        value: SystemUiOverlayStyle.light,
        child: BodyWidget(),
      ),//
    );
  }

Upvotes: 3

Views: 10168

Answers (3)

Ndiaga GUEYE
Ndiaga GUEYE

Reputation: 391

this work for me

@override 
Widget build(BuildContext context) {
return Scaffold(
  body: AnnotatedRegion<SystemUiOverlayStyle>(
    value: SystemUiOverlayStyle.light,
    child: BodyWidget(),
  ),
);
}

Upvotes: 9

Tim
Tim

Reputation: 171

Another effective way this can be done:

class MyWidget extends StatelessWidget {
  const MyWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle(
        statusBarColor: Colors.red,
        systemNavigationBarColor: Colors.red,
        statusBarIconBrightness: Brightness.dark,
        systemNavigationBarIconBrightness: Brightness.dark,
      ),
      child: Scaffold(),
    );
  }
}

Upvotes: 2

Nazmul Hasan
Nazmul Hasan

Reputation: 275

Hope this will help you

void main() {
  SystemChrome.setSystemUIOverlayStyle(
    const SystemUiOverlayStyle(
      statusBarColor: Colors.red,
    ),
  );
  runApp(MyApp());
}

Upvotes: 9

Related Questions