Flutter: ClipOval clipper elevation - flutter

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:

Related

Flutter InkWell on tap is not being detected

I am using inkwell to detect tap. I also use gesturedetector but that didn't work as well. Found a solution that say wrap the child with IgnorePointer, but that didn't work as well.
Here is my code:
Positioned(
bottom: -67,
child: GestureDetector(
onTap: () {
print('Tap');
},
child: Container(
width: 70,
height: 70,
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
border: Border.all(
color: Colors.white,
width: 5,
),
boxShadow: [
BoxShadow(
color:
Color(0xFF000000).withAlpha(11),
blurRadius: 16,
offset: Offset(0, 3),
),
],
shape: BoxShape.circle,
color: Colors.white,
),
child: CircleAvatar(
radius: 24,
backgroundColor: Colors.green,
child: Icon(
Icons.arrow_forward,
color: Colors.white,
),
),
),
),
),
This is the button on which i want to detect tap.
EDIT: It is detecting the tap but outside the white border of circle avatar. I want the whole White border and circle avatar to be clickable. Removing the positioned makes the whole container clickable but now how i want to position that element in the stack !!!
Remove Positioned widget and wrap the container in Inkwell

Flutter Text overflows parent container with border radius

I created a parent container with border radius circular but the text does not follow the same and overflows the container on the bottom left.How to make the text adjust to parent container?
Just add some padding using the padding parameter in your container and you are good to go!
Container(padding: EdgeInsets.all(10),)
You'll find everything about it here.
use the property clipBehavior and set it to Clip.antiAlias like the example below
Container(
margin: EdgeInsets.only(left: 10, right: 10),
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: const BorderRadius.all(Radius.circular(10)),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 6,
offset: const Offset(0, 3),
),
],
child: Container(
colors: Colors.amber,
child:Text('hello world'),
),
),
Just your text to new container and give the height and width to it, and do not to forget to change overflow property in Text widget. You can also wrap these widgets in to FittedBox, to size text to the container.

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.

Circle with inset shadow and gradient

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