1

I want to put opacity for container which contain hexadecimal color code.

This is my color:

const color_transparent_black = const Color(0x80000000); //50% 

As you can see i add 80 mean 50 % transparency.

return Scaffold(
  backgroundColor: Colors.amber,...
  Container(
    // card view
    alignment: Alignment.center,
    margin: EdgeInsets.only(
        top: 20.0, bottom: 10.0, left: 30.0, right: 30.0),
    decoration: BoxDecoration(
      boxShadow: ([
        BoxShadow(color: Colors.black, blurRadius: 5.0)
      ]),
      color: main_color_transparense_black,
      borderRadius: BorderRadius.circular(14.0),
    ),
    child: Column( ...

But Container is not transparent and it is completely black?I know with Opacity widget it is possible but i want to do this with color?

I read this post

This is not my answer.

Cyrus the Great
  • 5,145
  • 5
  • 68
  • 149

1 Answers1

3

The code has no issue with you Color(0x80000000)

You are seeing black color is due to the box shadow color back. BoxShadow(color: Colors.black, blurRadius: 5.0). Try to change your BoxShadow as per your needs. Try giving some offset value for the shadow.

krishnakumarcn
  • 3,959
  • 6
  • 39
  • 69