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

FlutterDartBorder

Flutter Problem Overview


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"),
),

Flutter Solutions


Solution 1 - Flutter

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

enter image description here

Solution 2 - Flutter

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.

Solution 3 - Flutter

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"),
        ),

Solution 4 - 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!'),
      ),
    );

Solution 5 - Flutter

also do can do as follows,

 borderRadius: new BorderRadius.only(
     topLeft: const Radius.circular(30.0),
     bottomLeft: const Radius.circular(30.0),
 ),

Solution 6 - Flutter

Also You can do it with 'Shape Function'.

  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.only(
      topRight: Radius.circular(15.0),
      topLeft: Radius.circular(15.0),
    ),

enter image description here

Solution 7 - Flutter

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShruti Ramnandan sharmaView Question on Stackoverflow
Solution 1 - FlutterArun R. PrajapatiView Answer on Stackoverflow
Solution 2 - FlutterJay MungaraView Answer on Stackoverflow
Solution 3 - FlutterMax MacfarlaneView Answer on Stackoverflow
Solution 4 - FlutterAshrafulView Answer on Stackoverflow
Solution 5 - FluttergsmView Answer on Stackoverflow
Solution 6 - FlutterNikhil S MaratheView Answer on Stackoverflow
Solution 7 - FlutterAbubakarView Answer on Stackoverflow