Home > Net >  how to make curve border using dart flutter?
how to make curve border using dart flutter?

Time:12-15

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

CodePudding user response:

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,),
  ],
);

CodePudding user response:

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.

  • Related