How to create a transparent container in flutter
3,808
Solution 1
try wrapping it inside the Opacity Widget
Opacity(
opacity: 0.5,
child: Container(child: Column(
children: [
Container(child: Text('Address: '), alignment: Alignment.centerLeft,),
Divider(color: Colors.grey,),
Container(child: Text('$address'), alignment: Alignment.centerLeft,),
],
),
color: Color(0xFF005D),
),
)
Solution 2
Try using Colors.transparent
+ withOpacity
for Container
.
Container(
color: Colors.transparent.withOpacity(0.5),
child: Column(
children: [
Container(
child: Text('Address: '),
alignment: Alignment.centerLeft,
),
Divider(
color: Colors.grey,
),
Container(
child: Text('$address'),
alignment: Alignment.centerLeft,
),
],
),
Author by
shalu j
Updated on December 27, 2022Comments
-
shalu j over 1 year
I want to make a container transparent like this:
Here's the container code:
: Container(child: Column( children: [ Container(child: Text('Address: '), alignment: Alignment.centerLeft,), Divider(color: Colors.grey,), Container(child: Text('$address'), alignment: Alignment.centerLeft,), ], ), color: Color(0xFF005D6C), );
If I give color: Color(0xFF005D6C).withOpacity(0.5) then, it is just making the color light like this
How can I make the container transparent?
-
shalu j over 3 yearsNow the container's background color is not coming.
-
pedro pimont over 3 yearsdo you have some kind of image in the background? because if you just have a white background below, the color will just appear to be lighter
-
shalu j over 3 yearsCurrently, I don't have any background image.
-
pedro pimont over 3 yearsSo thats probably the problem... Try adding something to the background and it'll be easier to se if your container got transparent
-
shalu j over 3 yearsI have given white color to the background, So, if I am giving green color to the container with some opacity, it should make the container transparent