Custom Container border in flutter - flutter

Hello friends I am new don't know how to make a custom border kindly help me to generate this type of border.
https://i.stack.imgur.com/MAlwG.png

Adding a border to a widget is very easy in Flutter. We just need to wrap the widget in a Container and add BoxDecoration to it.
Let’s say we want to make a square with blue borders all we need to do is:
Container(
height: 100,
width: 100,
decoration: BoxDecoration(
border: Border.all(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(10.0),
),
child: Center(
child: Text('mrflutter.com'),
),
),
Also in the link there are other types
Source
Also there is a tutorial about BoxDecoration widget
Boxdecoration tutorial

Related

How can I create this circles for my flutter UI?

I want to create those blue circles (you can see them on the picture), the app UI design was created with Figma.
I don't even know how to start, I'm new at flutter
Any ideas or tips?
You can start learning from flutter.dev.
There are many ways to do this. I am using Container with decoration
Container(
height: 70,
width: 70,
padding: EdgeInsets.all(10), //spacing using padding
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(width: 5, color: Colors.blue),
),
child: const Material( //inner circle
color: Colors.green,
shape: CircleBorder(),
),
)
More about Container.

Custom Container border in flutter for message

I am new in flutter i don't know how to make a custom border kindly help me to generate this type of border.
Use BoxDecoration in Container
Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.red, width: 0.1),
borderRadius: BorderRadius.all(Radius.circular(5))),
child: Text("Your Child Widget")
),
),
There are many more thing in Container you just need to find over internet.

Flutter: Smooth rounded corners

I would like to know how to make a smooth rounded corner in Flutter. I found a similar link to iOS approach - smooth rounded corners in swift but it did not help me find a solution to Flutter approach. I thought ContinuousRectangleBorder is the way, but it is not the shape I am looking for. I think some kind of clipper should work.
I published a dedicated package that might help you : figma_squircle.
Container(
height: 100,
width: 100,
decoration: ShapeDecoration(
color: Colors.red.withOpacity(0.75),
shape: SmoothRectangleBorder(
borderRadius: SmoothBorderRadius(
cornerRadius: 10,
cornerSmoothing: 0.5,
),
),
),
)
You can try the following code
ClipRRect(
borderRadius:
BorderRadius.circular(15.0),
child: // Your widget that needs to be rounded.
)
For more information, you can check this reference video
There is no natural way to do this with Flutter. If you really want to accomplish this, use the technique used in your article where you overlay the square with a circle with a Stack widget. This looks like the following:
Stack(children: [
Container(
height: 100,
width: 100,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
)),
Container(
height: 100,
width: 100,
decoration: BoxDecoration(
color: Colors.amber,
borderRadius: BorderRadius.all(Radius.circular(16)),
),
),
]),
This will create a square that looks like:
You might need to mess around with the height and width of the square and the circle but you get the idea.

How to create outlined Card widget in Flutter

I want to include a outlined material card with flutter, but since the card widget doesn't have a style element or something similar, I am not sure how to implement this.
I tried using the shape: property but wasn't very successful, mostly because I didn't understand how it works.
Output:
It has shape property which takes a Border you can change that.
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40), // if you need this
side: BorderSide(
color: Colors.grey.withOpacity(0.2),
width: 1,
),
),
child: Container(
color: Colors.white,
width: 200,
height: 200,
),
)
I think the screenshot you showed can also be achieved by just using elevation property of the Card.

Is there a way to sketch the background of the container in half on Flutter?

I know that I can use a gradient, but both gradient options are not suitable for me, since I need to fill the background of the container as a progress bar. I can use the CustomPainter, but by design the container has a border radius and I don’t know how to make a border radius using the CustomPainter. Are there any ideas how to do this?
one way would be to use a Stack widget
MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Some Stuff"),
),
body: Stack(
children: <Widget>[
Container(
height: 100.0,
width: 300.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.grey,
),
),
Container(
height: 100.0,
width: 100.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.blue,
),
),
],
),
),
);
When you are building the component you can access screen width and height using media query, divide it by any number you want and pass it as an argument to your Container for example.
Containter(
width: MediaQuery.of(context).size.width/2,
height: MediaQuery.of(context).size.height/2,
)
If you want to make it dynamic, you can replace numbers with variables and redraw based on changes of this variable.