Shalitha Jayamal
Shalitha Jayamal

Reputation: 171

Add hexa colors instead of Flutter defaults color values

I wanted to use Hexa color code for my flutter app using backgroundColor: Colors.#34A123. But I can only pickup flutter defaults values

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('CRICKDOM MOBILE'),
        backgroundColor: Colors.blue,
        leading:IconButton(
          icon: Icon(
            Icons.menu
          ),
          onPressed: (){},
        ),
 
        ],
    );

  }
}



`` 

Upvotes: 0

Views: 425

Answers (1)

pr0gramista
pr0gramista

Reputation: 9038

You have to use one of the constructors of Color class.

If you have RGB values then you can use:

Color c = const Color.fromRGBO(66, 165, 245, 1.0);

if you have HEX then you can use default constructor i.e for #ABCDEF use

Color myColor = const Color(0xFFABCDEF);

Note that the first 2 FF is the alpha channel - transparency. FF means completely visible. If you omit them your color will be fully transparent.

Upvotes: 1

Related Questions