-1

Container( color: Color('#260033'), height: 150.0, width: double.infinity, child: Column(

i want to use hex code to change the container color.pls help me regarding this.

Container( color: Color('#260033'), // showing error on this line height: 150.0, width: double.infinity, child: Column(

i want to change the background of container using this hex color code but unable to this..

3 Answers3

1

In flutter you have to use Color(0xff) with your hex code.

if you want to use the color #260033- use Color(0XFF260033)
FF represents full opacity. if you want to change the opacity replace FF with values in this table

        Container(
           color:Color(0xff260033),
           child: Text("some text"),
                 ),

Saad
  • 539
  • 2
  • 19
0

In flutter to give the hex code as color you can use this statement:

color: Color(0xff260033),
Munsif Ali
  • 1,839
  • 1
  • 8
  • 22
0

You cannot use strings as color.

You should use function Color to create color using hexadecimal int number.
The Color class expects an ARGB integer. Since you try to use it with an RGB value, represent it as int and prefix it with 0xff. In your case:

Container( color: Color(0xFF260033), ...
Alijvhr
  • 1,695
  • 1
  • 3
  • 22