How to change image color? - flutter

How to change the image color?
original image :
expect :
code :
Center(
child: Container(
height: 181.0,
width: MediaQuery.of(context).size.width - 46.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFB3E2D6),
Color(0xFF18A2A5).withOpacity(0.5),
],
),
),
child: Stack(
children: [
Positioned(
right: -20,
bottom: 0,
top: 0,
child: Image.asset(
'assets/images/border_background.png',
width: 220,
height: 220,
fit: BoxFit.cover,
),
),
Positioned(
right: -5,
bottom: 0,
top: 0,
child: Image.asset(
'assets/images/lisa-removebg-preview.png',
height: 151,
width: 207,
fit: BoxFit.cover,
color: Color(0xFF7CD2CC), colorBlendMode: BlendMode.modulate,
),
)
],
),
),
),
I try to create widgets and change the image color in the widget. but, not identical to the expectation
could you help me to fix some problems with this design?

For this you can use the ColorFilitered widget.
Without ColorFilter
Image.network("https://myImage"),
output:
With ColorFilter
ColorFiltered(
colorFilter:
ColorFilter.mode(Colors.teal.withOpacity(0.7), BlendMode.color),
child: Image.network(
"https://myUrl",
),
);
output:
You can change the Color with its opacity as you can see and also the Blendmode, more on Blendmodes here

Related

how to make widget disappear when overflow

i have created spotify login UI by using align widget to make typing comfortable. but the image above doesn't disappear or get pushed like the align widget. is there a solution to remove the image or detect if an overflow occurs?
Stack(
fit: StackFit.expand,
children: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xff96979C), Color(0xff636669), Color(0xff25252D)],
stops: [0.2, 0.5, 0.8]
),
),
),
Positioned(
top: medias.viewPadding.top + medias.size.height * 0.1,
left: 0,
right: 0,
child: Container(
height: 200,
width: 200,
child: Image(
image: AssetImage('assets/spotify.png'),
fit: BoxFit.scaleDown,
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: medias.size.height * 0.35,
child: Column(...),
),
),
],
),
Use column with the wrap of singleChildScrollView instead of the stack.
Something like this.
SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xff96979C), Color(0xff636669), Color(0xff25252D)],
stops: [0.2, 0.5, 0.8]
),
),
child: Column(
children: [
Container(
margin: EdgeInsets.only(top: 50),
height: 200,
width: 200,
child: Image(
image: AssetImage('assets/spotify.png'),
fit: BoxFit.scaleDown,
),
),
Container(
height: medias.size.height * 0.35,
child: Column(...),
),
],
),
),
)

Flutter Container height/width

Hey guys, so my problem is that the image should take all the space in the box (I got that) but the image looks weird.
Could you help me?
child: Container(
margin: const EdgeInsets.fromLTRB(10, 20, 10, 20),
decoration: BoxDecoration(
border: Border.all(
width: 2,
color: Colors.grey.shade700,
),
),
height: 350,
width: 350,
child: Container(
height: 350,
width: 350,
child: FittedBox(child: infoBank[PicNumber].image,
fit: BoxFit.fill,
),
),
),
You can do this using BoxFit.cover in your Image:
fit: BoxFit.cover
Alternatively, use BoxFit.fillHeight or BoxFit.fillWidth where appropriate for only one direction.
child: Image.network(
'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Peanuts_maize_chips_2.jpg/1920px-Peanuts_maize_chips_2.jpg',
fit: BoxFit.cover,
),

how to resolve flutter stack widget problems

SizedBox(
width: ScreenUtil().setWidth(197),
height: ScreenUtil().setHeight(117),
child: ClipRRect(
borderRadius: BorderRadius.circular(ScreenUtil().radius(30)),
child: Stack(
clipBehavior: Clip.none,
fit: StackFit.expand,
children: [
Image.asset(
"assets/images/image2.png",
fit: BoxFit.cover,
),
Positioned(
right: -15,
top: -15,
child: Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(15),
),
),
),
Positioned(
bottom: 10,
left: 12,
child: Text("naber lan"),
)
],
),
),
)
Why doesn't it go over the edges?Flutter inspector see outside but emulator same problem what can I do pls help what should i do.I tried everything
you are almost there but I think you miss the cliprect concept, when you used outside of stack it's clipping widget, you just put it inside stack.
Center(
child: SizedBox(
width: 197,
height: 117,
child: Stack(
clipBehavior: Clip.none,
fit: StackFit.expand,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(30),
child: Image.asset(
"assets/images/test.jpg",
fit: BoxFit.cover,
),
),
Positioned(
right: -15,
top: -15,
child: Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(15),
),
),
),
Positioned(
bottom: 10,
left: 12,
child: Text("naber lan"),
)
],
),
),
)
output:

how to blur bottom half of the screen in flutter

trying to blur the bottom half of the screen as no guideline or help available.
Requirement:-
i do not want to give specific width or height in backdrop filter child container.
what is already tried:
Stack(
fit: StackFit.expand,
children: [
Image.asset("assets/images/authpage.jpg",
height: double.infinity, width: double.infinity, fit: BoxFit.fill),
Positioned(
top: 500,
child: ClipRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
child: Container(
alignment: Alignment.center,
color: Colors.black.withOpacity(0.1),
),
),
),
),
],
);
Also tried the shader mask but that will fill with colors and not the blur part.
Stack(
fit: StackFit.expand,
children: [
ShaderMask(
shaderCallback: (rect) {
return LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.white, Colors.transparent],
).createShader(Rect.fromLTRB(0, 0, rect.width, rect.height));
},
blendMode: BlendMode.dstIn,
child: Image.asset(
'assets/images/authpage.jpg',
height: 400,
fit: BoxFit.fill,
),
),
],
);
i have tried but its not the best
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Container(
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
"https://images.unsplash.com/photo-1537734796389-e1fc293cf856?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=632&q=80",
))),
// color: Colors.blue,
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: ClipRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 2.0, sigmaY: 2.0),
child: Container(
// the size where the blurring starts
height: MediaQuery.of(context).size.height * 0.4,
color: Colors.transparent,
),
),
),
),
Positioned(child: Text("data"))
],
),
);
}
}

why Backdrop filter isn't working correctly flutter

I've tried to implement backdrop filter in flutter but It doesn't work.
ClipRect(
child:BackdropFilter(filter:ui.ImageFilter.blur(
sigmaX: 5.0,
sigmaY: 5.0,
),
child: Container(
child: (Image.file(
_image,
height: 400,
width: 400,
fit: BoxFit.cover,
)),
),
),
)
You have to use a stack and place the ImageFilter on top of the image you want to blur or you can use the colorBlendMode: property instead.
Container(
child: (Image.file(
_file,
height: 400,
colorBlendMode: BlendMode.overlay,
color: Colors.grey.withOpacity(0.5),
width: 400,
fit: BoxFit.cover,
)),
),
),
With stack -
child: ClipRect(
child: Stack(
children: <Widget>[
Card(
margin: EdgeInsets.only(right: 20),
elevation: 16,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20)),
child: Container(
height: 220 * _zoomAnim.value,
width: 150,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
image: DecorationImage(
fit: BoxFit.fitHeight,
image: AssetImage('images/tour$index.jpg'))),
),
),
Container(
height: 220,
width: 150,
child: BackdropFilter(
child: Container(
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.2),
borderRadius: BorderRadius.circular(20)),
),
filter: ImageFilter.blur(sigmaX: 1, sigmaY: 0),
),
),)...]))
Just wrap them into a stack and set the height for the container behind the image like this:
Note that in the below code I'am blurring the whole screen except for the image.
You can change the size of the blurred part by setting the container's size.
Stack(
children : [
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 5.0,
sigmaY: 5.0,
),
child: Container(
height: MediaQuery.of(context).size.height
color: Colors.white.withOpacity(0.4),
),
),
Container(
height: MediaQuery.of(context).size.height,
child: Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.file(
_image,
height: 400,
width: 400,
fit: BoxFit.cover,
),
),
),
)
],)