Container decoration image bug in Flutter web - flutter

Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/btn-img.png'),
fit: BoxFit.cover,
),
),
...
),
The bug is that the image of the container widget is misplaced (a little bottom relative to Container's position). Does anyone have experienced same problem?
Update
when I use another image with larger height, it works fine (My current image height is 302px)
Update2
The problem seems to be with color filter, when I disable color filter it works fine.

Related

Set container width according to image.network widh in flutter?

i want to fix my container size(width) according to the image which is getting from api(image.network..).So, how can i go for this?
i am trying to set dynamic width of container according to image which i get from image.network() in flutter.
You will get overflow error in your device when the image was bigger than your device screen. I recommend you to use this
Container(
width: 100,
height: 100,
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
'image link'),
),
),
),

How can I get this look on my welcome screen? flutter

I am trying to have a welcome screen like this:
I have all the lines from the bottom and the orange and blue bubbles as asset images. How can I stack them all together and then use Text() widget for the writing part?
You can use the Stack widget to stack its children if that answers your question:
Stack(
children: [
your_images_here,
your_text_here,
],
);
You can do it without using stack by using the image property in container decoration.
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/bg.png',
),
fit: BoxFit.cover,
)),
child: Column(
children: [
// your text widgets
])
),
So I had three images, and I couldn't use Imageprovider to use it as a background image of my main Container(). But, I decided to make a difference in my design by wrapping them all together using adobe photoshop and getting one image instead of three so that I can use ImageProvider instead of a stack. Then I used Decoration image and made the image the background of my page.

Flutter - Change image opacity of decoration image in container not going smooth

I have two containers 'Stack'ed one on top of another.
Both use decorationImage as a background. The one on TOP looks like the following:
Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(
color: Colors.transparent,
image: widget.imageAfter.isEmpty
? const DecorationImage(image: AssetImage('images/camera.png'))
: DecorationImage(
image: MemoryImage(base64Decode(widget.imageAfter)),
colorFilter: ColorFilter.mode(Colors.transparent.withOpacity(OPACITY), BlendMode.dstATop),
fit: BoxFit.cover),
border: Border.all(color: Colors.black, width: 1.0)
),
),
I change the value of opacity using a slider. when it goes 1, I can only see the image on top and at value 0 I can see the image at the bottom.
The problem I am facing is that the transition of the image transparency is not smooth when I am moving the slider. I get the result when I stop moving the slider but I am unable to see the transition in a smooth way. I guess this is because flutter is not able to draw the images in time. Is there way to do it?

Why does my image lose its gradient in flutter?

So I was trying to create a welcome page when I got this problem. At first, everything was fine, but when I insert an image using DecorationImage, it looks like my image has an error in the color gradient. The real image look like this:
But when i run my app, i get this:
I use PageView.Builder in Scaffold to show my images. My code look like this:
return Scaffold(
body: PageView.builder(
scrollDirection: Axis.vertical,
itemCount: img.length,
itemBuilder: (_,index){
return Container(
width: double.maxFinite,
height: double.maxFinite,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/image/"+img[index]
),
fit: BoxFit.cover
)
),
I put all my image names in a list and use the index to call each images.
The goldfish looks pretty much the same but the gradient at the bottom is disturbed. At first, I thought it was because I was using a low spec virtual device, but then I tried with a different virtual device and still got the same result. Why this happened? Does anyone know where I went wrong?
Edit: i try to add FilterQuality
return Container(
width: double.maxFinite,
height: double.maxFinite,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/image/"+img[index]
),
fit: BoxFit.cover,
filterQuality:FilterQuality.high
)
),
But nothing happen. Did I put it wrong?
i tried using real device and it works, but i don't know why

How do I get the effect of BlendMode.srcOver without making the rounded edges of Image to pointed ones?

I have a Container() that has a background image. This image already has rounded corners, so I haven't used any borderRadius. I want to add a color filter to this image with some opacity. So, I have used this :
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/signup_bg.png"),
fit: BoxFit.contain,
colorFilter: ColorFilter.mode(
Color(0xFFEDDFD0).withOpacity(0.80),
BlendMode.srcOver,
)),
color: Color(0xFFE5E5E5),
),
),
Now, if used BlendMode.modulate, then the corners of the image remain rounded but the color of the filter changes a bit even if I keep Color(0xFFEDDFD0) as the same. How do i achieve the effect of BlenMode.srcOver without making the rounded edges of the image turn into pointed edges.
PS: Also, in my case I can't change the fit property to anything other than BoxFit.contain.