How to put transparent color for container in flutter

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.

flutter
flutter-layout
asked on Stack Overflow May 29, 2020 by Cyrus the Great

1 Answer

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.

answered on Stack Overflow May 29, 2020 by krishnakumarcn

User contributions licensed under CC BY-SA 3.0