Want to set the primarySwatch as white in flutter

393 Views Asked by At

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

There are 2 best solutions below

0
On BEST ANSWER

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,
    ),
  );
0
On
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());
}