how to make custom container like this: - flutter

enter image description here
I need to make this custom container
I tried more to make it by border radius but I can not do it and I wish stack over flow do it

You can set the border radius for each corner using DecoratedBox:
Center(
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.deepOrangeAccent.shade200,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(100),
bottomRight: Radius.circular(4),
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: const SizedBox(
height: 100,
width: 100,
),
),
),

Try the following code:
Container(
height: 100.0,
width: 100.0,
decoration: BoxDecoration(
color: Colors.orange[100],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(15.0),
topRight: Radius.circular(15.0),
bottomLeft: Radius.circular(100.0),
bottomRight: Radius.circular(5.0),
),
),
),

Related

FLUTTER: how to set my Drawer background image width to Drawer width

want to add a background image to my drawer. I want to fix my background image over Drawer width
Drawer(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(40),
bottomRight: Radius.circular(40),
topLeft: Radius.circular(40),
bottomLeft: Radius.circular(40),
),
),
child: Stack(children: <Widget>[
Image.asset(
"assets/images/menu.png",
width: double.infinity,
fit: BoxFit.cover,
),
Wrap your Image.asset in a Positioned.fill(child: Image.asset ... ).
This should make it expand to fill the Stack.
Try the following code:
Drawer(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(40),
bottomRight: Radius.circular(40),
topLeft: Radius.circular(40),
bottomLeft: Radius.circular(40),
),
),
child: Stack(children: <Widget>[
Image.asset(
"assets/images/menu.png",
width: MediaQuery.of(context).size.width,
fit: BoxFit.cover,
),

How to draw a leaf design of floatingactionbutton in flutter?

I need this design
I used this code
borderRadius: BorderRadius.only(topRight: Radius.circular(40.0), bottomLeft: Radius.circular(40.0)),
but I am getting this result
just increase the radius of button
Container(
height: 250,
width: 250,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.only(
topRight: Radius.circular(400.0),
bottomLeft: Radius.circular(400.0)),
),
),

How to make curve border using dart flutter?

I have tried borders, but I didn't get the actual result. Actually, I need this type of border/shape like bottomRight.[enter image description here][1]
See image: https://i.stack.imgur.com/LVtTQ.png
You can achieve it by using Container with BorderRadius.only like below:
return Container(
width: 100.0,
height: 150,
padding: const EdgeInsets.all(20.0),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.zero,
topRight: Radius.zero,
bottomLeft: Radius.zero,
bottomRight: Radius.circular(20.0),
),
),
);
or if you have that triangle png image, you can stack it to the bottom right like this:
return Stack(
alignment: Alignment.bottomRight,
children: [
Container(
width: 100.0,
height: 150,
padding: const EdgeInsets.all(20.0),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.zero,
topRight: Radius.zero,
bottomLeft: Radius.zero,
bottomRight: Radius.circular(20.0),
),
),
),
Image.asset("images/paper_flip.png", width: 30, height: 30,),
],
);
Try to put a container in the stack with box-shadow and use a positioned widget to bring it to the bottom right corner.
For example:
use stack and this stack have 3 widgets
one is the rectangle with border and
the other one is the smaller white rectangle on the first widget to cover the black border and
the last one is the triangle with box-shadow
remember to use box-shadow with both widgets and
positioned widget will put both of them to the right bottom corner
A different solution you can use is a custom image, but you will struggle with the responsiveness.
I hope it helped. 😊
Refer this code:
Container(
height: 90,
width: 90,
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
margin: EdgeInsets.only(left: 3.0, right: 3.0, bottom: 5.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(0.0),
topRight: Radius.circular(0.0),
bottomLeft: Radius.circular(0.0),
bottomRight: Radius.circular(18.0)),
),
child: Text(
"Hai hello" ?? "",
),
),

How to draw rounded rectangle with borders only on top?

There are multiple ways to draw a rounded rectangle. I want to draw a rounded rectangle with content inside. However, only the top of the rectangle should be rounded.
I tried
Container(
decoration:
BoxDecoration(border: Border(top: BorderSide(color: Colors.red))),
child: Column(
children: [Text("hello")],
));
but I get a red line with "hello" on bottom. Makes no sense.
With BorderRadius.vertical you can choose top corners or bottom corners.
decoration: BoxDecoration(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
And with BorderRadius.only you can choose any corner.
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
It's a little trick
Container(
height: 100,
width: 150,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.all(
const Radius.circular(15.0),
),
),
child: Container(
margin: const EdgeInsetsDirectional.only(top: 2),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(13.0),
topRight: const Radius.circular(13.0),
),
),
child: Column(
children: [
Text("hello"),
],
)
),
)
Try this
Container(
decoration: ShapeDecoration(
color: Colors.yourColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
),
),
),

How to make one side circular border of widget with flutter?

I'm trying to build one side circular border with Container widget in flutter.
I have searched for it but can't get any solution.
Container(
width: 150.0,
padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(30.0),
/* border: Border(
left: BorderSide()
),*/
color: Colors.white
),
child: Text("hello"),
),
Use BorderRadius.only and provide the sides
return Center(
child: Container(
height: 100,
width: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(40),
),
border: Border.all(
width: 3,
color: Colors.green,
style: BorderStyle.solid,
),
),
child: Center(
child: Text(
"Hello",
),
),
),
);
Output
You can achieve this by following code for creating your widget :
return Container(
width: 150.0,
padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.zero,
bottomLeft: Radius.zero,
bottomRight: Radius.zero,
),
),
child: Text(
"hello",
),
);
This way you can have your top left sided circular border with Container widget in flutter.
Another way of doing this is to use the ClipRRect widget.
Simply wrap your widget with ClipRRect and give a radius.
You can specify which corner you want to make round.
ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(10)),
child: Container(
height: 40,
width: 40,
color: Colors.amber,
child: Text('Hello World!'),
),
);
If you want one side of a container rounded you want to use BorderRadius.only and specify which corners to round like this:
Container(
width: 150.0,
padding: const EdgeInsets.all(20.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(40.0),
bottomRight: Radius.circular(40.0)),
color: Colors.white),
child: Text("hello"),
),
Also You can do it with 'Shape Function'.
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(15.0),
topLeft: Radius.circular(15.0),
),
also do can do as follows,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(30.0),
bottomLeft: const Radius.circular(30.0),
),
You can also set the radius of each side.
margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
fromLTRB= from Left, Top, Right, Bottom