fluttershapesflame

Rectangle component with round corners


I was googling for a solution on how to create a rectangle with round corners in Flame (Flutter), but didn't find any related examples or ideas.

Is there a way to do this?

I was trying to find a solution, but the only idea I have for now is to use SVG.


Solution

  • I cant find anything related to rounded corner in docs .You can try extending shape component

    https://docs.flame-engine.org/main/flame/components.html

    class RoundedRectangleComponent extends ShapeComponent {
     RoundedRectangleComponent(double radius)
         : super(
             shape: RoundedRectangleBorder(
               borderRadius: BorderRadius.circular(radius),
             ),
           );
    }
    
     add(RoundedRectangleComponent(30.0));