Shadow blur efect in flutter - flutter

How can I create this shadow blur in the top and bottom of the Widget that appears to be on top of the list?

try to wrap your child with Stack and a mask:
Stack(
children: [
//_yourWidget(),
Opacity(
opacity: 0.5,
child: Container(
width: 50.0,
height: 50.0,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[
Colors.black,
Colors.transparent,
Colors.transparent,
Colors.black,
],
stops: [
0,
0.2,
0.8,
1,
],
),
),
),
),
],
)

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(...),
),
],
),
),
)

How to have two gradients side by side in flutter

I want to have two linear gradients side by side without putting them inside a different Container() each
My code:
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
// Instead of two different colors here I want to have the two other Linear gradients
// with each having two other different colors that go from top to bottom
Color(0xff5a0dbe),
Color(0xff004773),
],
stops: [0.5, 0.5],
tileMode: TileMode.clamp,
),
),
child: const Center(
child: Text(
"sds",
style: TextStyle(color: Colors.white),
)),
),
What I got is
What I want is
You can just use a Column to place the widgets as you described on comment, no need to worry about positioning widget. Using Stack with two Container
return Scaffold(
body: LayoutBuilder(
//for future purpose if needed
builder: (context, constraints) {
return Stack(
alignment: Alignment.topCenter, // defult topLeft
children: [
Row(
children: [
Expanded(
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xff5a0dbe),
Color(0xff004773),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
// stops: [0.5, 0.5],
// tileMode: TileMode.clamp,
),
),
),
),
Expanded(
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xff00436D),
Color(0xff031420),
],
// stops: [0.5, 0.5],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
// tileMode: TileMode.clamp,
),
),
),
),
],
),
SizedBox(
// dont need it,
width: constraints.maxWidth,
height: constraints.maxHeight,
child: Column(
// do everything on column
children: [
],
),
)
],
);
},
),
);

Flutter - How to get linear gradient across all edges?

LinearGradient(
//tileMode: TileMode.clamp,
colors: [
kRecordButtonColor.withOpacity(0.4),
kRecordButtonColor,
kRecordButtonColor,
kRecordButtonColor.withOpacity(0.4),
],
stops: const [
0,
0.2,
0.8,
1,
],
),
As you can see this code only helps me get gradients across 2 edges, I need it along all 4 edges.
Try this instead of your Container:
Stack(
alignment: Alignment.center,
children: [
Container(
margin: EdgeInsets.all(16.0),
width: 55,
height: 55,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(10),
gradient: LinearGradient(
colors: [
Colors.red.withOpacity(0.5),
Colors.red,
Colors.red,
Colors.red.withOpacity(0.5),
],
stops: const [
0,
0.2,
0.8,
1,
],
)),
),
Container(
margin: EdgeInsets.all(16.0),
width: 55,
height: 55,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(10),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white.withOpacity(0.5),
Colors.white.withOpacity(0.0),
Colors.white.withOpacity(0.0),
Colors.white.withOpacity(0.5),
],
stops: const [
0,
0.2,
0.8,
1,
],
)),
),
],
),

How to add gradient color in card?

How to add gradient color in the background of a card ? Should I reproduce this card with a container and a box decoration or is there another simple way ?
Try below code hope it help to you in below answer change Color your need.
Card(
child: Container(
height: 50,
width: 150,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.yellow,
Colors.orangeAccent,
Colors.yellow.shade300,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: Container(), //declare your widget here
),
),
Your Card look like->
If you are gradient background to card or gradient border to card try below code
Container(
height: 50,
width: 150,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.yellow,
Colors.orangeAccent,
Colors.yellow.shade300,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child:Card(
color:Colors.white,
child: Container(), //declare your widget here
),
),
Your Screen like ->
I know it's a bit late, but you can try this to achieve a card gradient with border radius
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black38,
blurRadius: 3.0,
spreadRadius: 0.0,
offset: Offset(1.0, 1.0),
)
],
gradient: LinearGradient(
colors: [startColor, endColor],
begin: Alignment.bottomLeft,
end: Alignment.topRight,
),
),
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 6),
TextWidget(
title,
typographyToken: TypographyToken.text14SemiBold,
color: Colors.white,
),
const SizedBox(height: 8),
TextWidget(
"$pendingCount Pending Request",
typographyToken: TypographyToken.text10,
color: Colors.white,
),
const SizedBox(height: 6),
],
),
),
);
Result :
result
This is a sample that I tried just now. Works fine for me.
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.black, Colors.white],
begin: Alignment.topLeft,
end: Alignment.bottomRight)),
)
Another way and probably the best in my opinion:
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerRight,
end: Alignment.center,
colors: [Colors.deepOrangeAccent, Colors.orange],
),
),
width: 300,
height: 300,
child: Card(
color: Colors.transparent,
),
),
Output:
Click here to view
Card(
shadowColor: tabColorAmber,
elevation: 10,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
gradient: LinearGradient(colors: [
Colors.orangeAccent,
Colors.orangeAccent,
Colors.yellow.shade100,
])),
width: double.infinity,
height: 140,
),
),
Example

How to send back the boxShadow from gradient?

I want to make a container with gradient color and shadow. But shadow is always front from the gradient.
How can i fix this?
Container(
width: 184,
height: 127,
decoration: new BoxDecoration(
gradient: new LinearGradient(colors: [
Color(0xFFFFC1CD).withOpacity(0.6),
Color(0XFFA5E8FF).withOpacity(0.6),
], stops: [
0.0,
1.0
], begin: FractionalOffset.topCenter, end: FractionalOffset.bottomCenter, tileMode: TileMode.repeated),
boxShadow: [
BoxShadow(
color: Color(0xFF797D7F),
offset: Offset(0, 10),
blurRadius: 10,
spreadRadius: 0.5,
),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {},
child: Center(
child: Text("Hi"),
)),
),
),
Make a container with box shadow and make the one with the gradient a child of it