Circle with inset shadow and gradient - flutter

I wonder how to achieve the following effect. A circle with an inset shadow that also has a gradient.
I managed to get an inset shadow but with even color. I would need a gradient on the inset I think.
Container(
height: 300,
decoration: BoxDecoration(
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Color(0xffa3b1c6), // darker color
),
BoxShadow(
color: Color(0xffe0e5ec), // background color
spreadRadius: -12.0,
blurRadius: 12.0,
),
],
),
),
Gives the following:

Design like that is called Neumorphic design.
The central point of Neumorphism are shadows, which are giving the interface this feel of a surface carefully carved with a spherical drill.
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(bevel),
color: Colors.grey.shade200,
boxShadow: [
BoxShadow(
blurRadius: bevel,
offset: -blurOffset,
color: Colors.white,
),
BoxShadow(
blurRadius: bevel,
offset: blurOffset,
color: Colors.grey.shade400
)
]),
child: child,
);
The above code creates a white bevel for light and a dark one for shadow.
But this medium article shows how you can do it better.
There's also this nifty library that I use called the neumorphic container library that helps to handle this for me.
EDIT: #nilsi shared a much better library that makes neumorphic design simple in flutter: flutter_neumorphic

Related

How do you add a border to a container with border radius? [duplicate]

This question already has answers here:
Add border to a Container with borderRadius in Flutter
(7 answers)
Closed 11 months ago.
I want to add a bottom border to a container that has border radius along the top only. I can see that I cannot add borderRadius and border together in BoxDecoration property. How could I achieve the below look and feel using containers?
So far I can only achieve either rounded corners or have a bottom border, but not both. I want rounded corners across the top and a border across the bottom. Thank you very much!
Container(
padding: const EdgeInsets.all(20),
decoration: const BoxDecoration(
color: Color(0xFFE9F6EB),
// boxShadow: [BoxShadow(color: Colors.green, spreadRadius: 3)],
borderRadius: BorderRadius.only(
topLeft: Radius.circular(6), topRight: Radius.circular(6)),
// border:
// Border(bottom: BorderSide(width: 3.0, color: Colors.green)),
),
child: Row(children: [
const Icon(Icons.check_circle,
color: Color(0xFF69A258), size: 40),
const SizedBox(width: 15),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text("Valid",
style: TextStyle(color: Colors.green, fontSize: 18)),
Text("Document successfully validated.")
])
]),
),
By adding a boxshadow instead of a border with a spreadRadius of 0. Basically BoxShadow property followed the same concepts as css so this generator helped alot https://cssgenerator.org/box-shadow-css-generator.html
boxShadow: [
BoxShadow(
color: Colors.green, spreadRadius: 0, offset: Offset(0, 3))
],

Inside glow on textfield in flutter

I have a textfield that has a kind of transparent background with border and then some kind of glow on the inside that makes it pop.
I need help as I don't know how to achieve this glow. I have tried wrapping the textfield in a container with a linear gradient, but it only makes the glow appear at one edge.
Here is a picture of what I have currently and what I want, side by side.
left is what I have, and the right is what I'm trying to achieve
You are trying to add inner shadow with blur. Use BoxDecoration in Container and tweak spreadRadius and blurRadius as per your need.
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.blue[500]!,
),
BoxShadow(
color: Colors.blue[900]!,
spreadRadius: -5.0,
blurRadius: 5.0,
),
],
),
child: TextField(
obscureText: true,
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
),

How to remove elevation shadow from one side without removing elevation itself in flutter from Card or Material widget?

How can I remove top-side elevation shadow inside Card or Material widget.
I used Material widget to container and given a value for elevation. it reflects to my container in all side. But i want only left, bottom and right side elevation shadow. how can i get it or remove top side elevation shadow.
Example from Material or Card Widget will be useful.
Material(
elevation: 3,
child: Container(
height: 100,
width: 300,
),
)
For that, you just have to bring the shadow a little bit down by increasing the y-axis of the offset property just like this:
Container(
height: 100.0,
width: 300.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.white,
boxShadow: [
BoxShadow(
spreadRadius: 2,
blurRadius: 3,
offset: Offset(0, 6),
color: Colors.black38
)
]
),
),
Here's the output:

flutter only bottom shadow to container

i have tried many solution but i couldn't get what i want.
https://stackoverflow.com/a/56744034/4862911 i applied in this answer but couldn't get correct response. There is still shadow top of container. How can i achieve it?
and also i have tried to surround my widget with Material . but still can't solve the problem.
Material(
elevation: 5,
child: Container(
height: 50,
child: _buildEloAndLevel(),
),
),
Material(
elevation: 5,
child: Container(
height: 50,
child: _buildEloAndLevel(),
// add boxShadow
decoration: BoxDecoration(
boxShadow: [
color: Colors.black54,
blurRadius: 15.0,
],
),
),
),
This will create a shadow of 15 units arounds the Container. Now, the shadow can be moved with the offset property. Since, we don't want shadow on top, we can move it down by 15 units.
Material(
elevation: 5,
child: Container(
height: 50,
child: _buildEloAndLevel(),
// add boxShadow
decoration: BoxDecoration(
boxShadow: [
color: Colors.black54,
blurRadius: 15.0,
offset: Offset(0, 15), // horizontally move 0, vertically move 15,
],
),
),
),
I don't know if other examples are really setting a shadow for only bottom, but here is a know solution:
Container(
height: 50.0,
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black54,
blurRadius: 20.0,
spreadRadius: -20.0,
offset: Offset(0.0, 25.0),
)
],
color: Colors.red,
),
),
Set the blur of the shadow with blurRadius and then set the spreadRadius to negative the blurRadius then use the dy property of the Offset() constructor, you set it to positive values to control the shadow bottom.
All you need to do is playing around with your offset's value. And I think you don't need to wrap it with Material.
Offset is the displacement of the shadow from the box. It requires 2 double-types values, Offset(x, y);
Example:
Container(
height: 50.0,
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black54,
offset: Offset(15.0, 20.0),
blurRadius: 20.0,
)
],
color: Colors.red,
),
),
TIPS FROM ME: To make sure the shadow doesn't show up in the top of your container, make sure your blur radius is not bigger than your Offset's y-value.

Flutter: ClipOval clipper elevation

Bottom Shadow
Hi I am new to flutter and trying to create this design from Shakuro of dribble. I am getting trouble trying to create elevation for the clipper because the whole rectangle is getting the shadow instead of the clipper only.
Is there a way to put elevation or similar effect like shadow underneath the clipper?
You can wrap your child inside a Container with Circle shape in your BoxDecoration like this:
new Container(
height: 300.0,
width: 300.0,
child: Center(child: Text("Your child here")),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey,
blurRadius: 5.0,
offset: Offset(5.0, 5.0),
spreadRadius: 5.0)
],
),
)
Result: