casmang
casmang

Reputation: 405

Flutter - How to use an RGB or HEX value for a Widget Container Color

I have a container in my app that I would like to use a specific fill color for but i have bee unable to figure it out. I have no problem specifically using the Colors.grey[500] but I would like to use a color that isn't in the Material Color library. I would really like to use color: new Color.fromRGBO(200, 150, 150, 1.0) but this throws an error.

Can anyone point me in the right direction to be able to assign an RGB or a HEX value to a widget color: attribute?

The error/warning I was getting when I hover over the line of code in Android Studio:

The argument type 'Color(...color.dart)' can't be assigned to the parameter 'Color(...painting.dart)'

Upvotes: 0

Views: 2522

Answers (1)

casmang
casmang

Reputation: 405

It looks like I had made the mistake myself. I had previously included the color.dart package shown below:

import 'package:color/color.dart';

It was causing the conflict/error I was receiving. When I would hover over the error in the Android Studio editor, I would get the warning/error:

The argument type 'Color(...color.dart)' can't be assigned to the parameter 'Color(...painting.dart)'

Once I removed that import, the code I was trying to use worked just fine.

Upvotes: 1

Related Questions