Search code examples
flutterdart

What's the difference between BorderRadius.all(Radius.circular(4)) and BorderRadius.circular(4)


Both of that implementations are doing the same, which is rounding a child with a BorderRadis:

ClipRRect(
 borderRadius: BorderRadius.circular(4),
 child: /*...*/
 )


ClipRRect(
 borderRadius: const BorderRadius.all(Radius.circular(4)),
 child: /*...*/
 )

is there a major difference between them, and what should I use?


Solution

  • There is no difference, they are identical.

    BorderRadius.circular() is just a convenience constructor.

    The implementation of .circular() calls for .all() with Radius.circular():

    BorderRadius.circular(double radius) : this.all(
      Radius.circular(radius),
    );