1

When I'm using (Colors.amberAccent) in Flutter framework, the color square appears automatically. How can I show it in Android studio beside Lines number if I'm using Color.fromARGB(255, 100, 100, 23)?

The second question is, can I use this color style (#ff0000) in Flutter framework?

I've put an image to clear my idea.colors

1
  • see Colors#fromHexString Commented Nov 9, 2018 at 8:43

3 Answers 3

1
String color = '#ff0000';
String hex = color.replaceAll("#", "");
Color col = Color(int.parse(hex, radix: 16)).withOpacity(1.0);

P.S. Or, you can use this

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

Comments

1

To answer your first question: It is not possible to display the color in the IDE when you use something else that Colors.colorName.

For your second question: you can use the style you described with this syntax Color(0xff5600). That will return a Color object instance

return new MaterialApp(
  title: appTitle,
  theme: new ThemeData(
    primarySwatch: : Color(0xff5600),
  ),
  home: ...
);

Comments

0

The color square will appear if you put the color as a constant:

Color color = const Color(0xFF536DFE);

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.