0

I want to change the colour of the system navigation bar but I can't.

I got this:

 import 'package:flutter/services.dart'
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);

but it didn't work for me...

I used the code below to change the status bar colour it worked.

import 'package:flutter/services.dart'
systemOverlayStyle: SystemUiOverlayStyle(statusBarColor: Colors.white),

3 Answers 3

1

In your MaterialApp, you should change the primaryColor:

MaterialApp(
  theme: ThemeData(primaryColor: Colors.grey,),
  home: AppHome(),
),
Sign up to request clarification or add additional context in comments.

1 Comment

What about custom colours that are not part of MaterialApp theme?
0

Wrap your parent widget

AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle(
        systemNavigationBarColor: systemNavigationBarColor,
      ),

Comments

0

If you are changing color of a specific screen/widget, use SafeArea above Scaffold and wrap SafeArea with Container then try using color of that container.

class TestScreen extends StatelessWidget {
  const TestScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: SafeArea(
        child: Scaffold(
          appBar: AppBar(),
          body: const Center(
            child: Text('Test Screen'),
          ),
        ),
      ),
    );
  }
}

If you want the change for app level the trying using this code in main function of the app :

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.