-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 Answers 3

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"),
                 ),

Sign up to request clarification or add additional context in comments.

Comments

0

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

color: Color(0xff260033),

Comments

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), ...

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.