Create a Container witch shape is like image(see attached image) - flutter

see below image
I want create a container(or other widget) with custom shape that like same as image.
I don't want create content in that, just shape of that.
This isn't BorderRadius, because those sides is curved.(I want create this sides like that image).
I prefer that implemented without CustomPaint.
Thank you

It totally border radius bro just try The width & height
Align(
child: Container(
height: 50,
width: 100,
margin: EdgeInsets.only(top: 40, left: 40, right: 40),
decoration: new BoxDecoration(
color: Colors.green,
border: Border.all(color: Colors.black, width: 0.0),
borderRadius: new BorderRadius.all(Radius.elliptical(100, 50)),
),
child: Text(' '),
),
),

Related

How to create this curved effect using flutter with clippath

HOW TO CREATE THIS?
Its like a ListTile or something with this curve effect in start of it, as of now it won't animate just the next option will be selected onTap but I'm unable to create this effect. I tried it with radius but that's not resulting out to be exact match of this. The code is below.
MY TRY SO FAR
Code
Container(
color: AppTheme.c.primary,
width: 200,
height: 60,
child: Row(
children: [
Container(
width: 50,
height: 60,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.horizontal(
right: Radius.elliptical(
MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height,
),
),
),
),
],
),
),

How can I apply notch curve to Widget?

I have a design as you can see below and the question is how can I apply this notch effect on Arrow ? Is there any easy way to do it just like in Floating Action Button ? Thanks in advance.
I have created Dartpad, please look into this and do let me know if you need any help.
Dartpad Link : https://dartpad.dev/flutter?9bd55396e067e71a839851e18905f478
Code:
Padding(
padding: const EdgeInsets.all(16.0),
child: SizedBox(
height: 70,
child: Stack(alignment: Alignment.centerRight, children: [
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: Container(
height: 70,
decoration: BoxDecoration(
color: Colors.cyan, borderRadius: BorderRadius.circular(8)),
),
),
Container(
width: 40,
height: 65,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 5)),
child: FloatingActionButton(
onPressed: () {},
backgroundColor: Colors.cyan,
child: const Icon(Icons.chevron_right),
),
)
]),
),
);
Output:
Hey you can achieve it in 2 way
1st one and simple - Create a box decoration widget and a circle shape widget with white border and put these together with Stack and fit as per your requirements.
2nd use Custom Clipper or Custom Paint and draw your shape.

Can't resize svg picture in flutter

I need to make an svg image size like on the photo below
But when i'm trying to give this size through SvgPicture.asset constructor or with a SizedBox it doesn't make any effect and i'm getting something like this
here is my code of that widget
Container(
width: 80,
height: 80,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: yellowGradient,
),
child: SizedBox(
height: 29,
width: 45,
child: SvgPicture.asset(
dishIconPath,
color: whiteIconColor,
),
),
),
I think that my Svg picture stretches to container size but i don't know what causes such a behaviour because there is SizedBox
Container doesn't know how to align the child if it is smaller than the container itself, so it expands it to fill the containers size.
The SizedBox can also be removed as SvgPicture.asset(...) now accepts size parameters.
Based on the above information, a possible solution for you will be the following, the important bit being the addition of alignment: Alignment.center:
Container(
width: 80,
height: 80,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: yellowGradient,
),
child: SvgPicture.asset(
dishIconPath,
color: whiteIconColor,
height: 29,
width: 45,
),
),
For further information, refer to "Layout behaviour" in the Container widget documentation here.
you can use padding or margin
Container(
width: 40,
height: 40,
padding: const EdgeInsets.all(15),
child: SvgPicture.asset(
"assets/icons/outline/edit2.svg",
),
);
Instead of wrapping it with a SizedBox, use the fields height and width of the SvgPicture.
SvgPicture.asset(
dishIconPath,
color: whiteIconColor,
height: 29,
width: 45,
),

How to add gradient color to Divider in Flutter

I have a Divider widget with a solid color but I want to set it to a gradient color. Is there a way to do this?
Divider(
height: 20,
thickness: 2.5,
indent: 0,
endIndent: 100,
)
Just use a Container() with [BoxDecoration][1] to create a gradient.
SizedBox(
width: 200,
height: 4,
child: Container(
decoration: BoxDecoration(
gradient: //...
),
),
),
The pre-defined divider is good but not powerful when it comes to customization.
[1]: https://api.flutter.dev/flutter/painting/BoxDecoration-class.html
If you wish to use the exact same parameters as the official Divider and yet have the possibility to gradient AND to round these nasty square sides, you can use this ds is my DividerStyle containing the parameters:
return SizedBox(
height: ds.heigth,
child: Center(
child: Container(
height: ds.thickness,
margin: EdgeInsetsDirectional.only(start: ds.indent, end: ds.endIndent),
decoration: BoxDecoration(
color: ds.color.getColor(),
gradient: ds.color.getGradient(),
borderRadius: ds.roundEdge
? BorderRadius.all(Radius.circular(ds.thickness))
: null,
border: Border.all(color: Colors.transparent, width: 1),
),
),
),
);

Flutter image decoration misplaced

I'm playing around with Flutter framework, and got stuck with this problem. I have an image, and I'm adding a decoration to it, but the decoration is being drawn in the center of the screen, while the image is aligned to the left.
Here's the code for the card:
final pokemonThumbnail = new Container(
decoration: new BoxDecoration(
color: Colors.grey,
shape: BoxShape.circle,
),
margin: new EdgeInsets.symmetric(
vertical: 16.0
),
alignment: FractionalOffset.centerLeft,
child: new Image(
image: new AssetImage('assets/img/' + pokemon.id.toString() + '.png'),
height: Theme.Dimens.pokemonHeight,
width: Theme.Dimens.pokemonWidth,
),
);
And here's the image of how it's being rendered.
The pokemons are the image elements, and the grey circle in the middle is its decoration. I was expecting that the decoration was rendered centered to it's owner, which is the image. Am I assuming something wrong here?
You can make the Image inside a FittedBox and after that apply the decoration to the child
final pokemonThumbnail = new Container(
margin: new EdgeInsets.symmetric(vertical: 16.0),
alignment: FractionalOffset.centerLeft,
child: new FittedBox(
child: new Container(
decoration: new BoxDecoration(
color: Colors.grey,
shape: BoxShape.circle,
),
child: new Image(
image: new AssetImage('assets/img/' + pokemon.id.toString() + '.png'),
height: Theme.Dimens.pokemonHeight,
width: Theme.Dimens.pokemonWidth,
),
),
),);