skip to Main Content

how to change the ‘primarySwatch’ to white in the app bar – Flutter?

This is what I have:

,

I want to change the blueGrey (portion marked in red) to white. While trying to change this from

        primarySwatch: Colors.blueGrey,

to

        primarySwatch: Colors.white,

en error is showing as "The argument type ‘Color’ can’t be assigned to the parameter type ‘MaterialColor?’. "

I want to get it like this:

Tried to change the primarySwatch to ‘Colors.White’, created a class ‘basicColors’and added colors(colorHexcode) to variables in the class. Tried to call them in the position of ‘Colors.white’ as ‘basicColors.varibleName’. Didn’t work though.

2

Answers


  1. Add below code in your main() function and import below library

    import 'package:flutter/services.dart';
    

    inside main function

      SystemChrome.setSystemUIOverlayStyle(
        const SystemUiOverlayStyle(
          statusBarColor: Colors.transparent,
        ),
      );
    
    Login or Signup to reply.
  2. import 'package:flutter/services.dart';
    
    void main() {
    
      SystemChrome.setSystemUIOverlayStyle(
        const SystemUiOverlayStyle(
          statusBarColor: Color(0xffF9FAFC), //onlyForAndroid
          statusBarIconBrightness: Brightness.dark, //onlyForAndroid
          statusBarBrightness: Brightness.light, //onlyForIOS
        ),
      );
    
      runApp(const MyApp());
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search