I am getting a warning when using following code but my app is running fine:
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during paint():
A borderRadius can only be given for uniform borders.
'package:flutter/src/painting/box_border.dart':
Failed assertion: line 510 pos 12: 'borderRadius == null'
Here is my code:
Container(
height: screenSize.height*.13,
width: AppSize.medium,
decoration: BoxDecoration(
color: Colors.red,
border: Border(
right: BorderSide(
width: 1.0,
color: Colors.blue
),
),
borderRadius: BorderRadius.only(
topRight: Radius.circular(AppSize.small),
bottomRight: Radius.circular(AppSize.small),
)
),
)
It's not possible to add border: and borderRadius: at the same time, you'll get this error: A borderRadius can only be given for uniform borders. You can achieve what you want using the borderRadius: and a boxShadow: instead of border: like this:
A borderRadius can only be given for uniform borders. You can achieve what you want using the borderRadius: and a boxShadow: instead of border: like this:
Flutter is complaining because you only apply a right border to your container, but want to have a border radius as well. Flutter expects the border to be uniform, i.e. all the way around and in the same color, when applying border radius. If you jump to the sources where the assertion error was thrown you can have a look at the actual assertion.
Flutter is complaining because you only apply a right border to your container, but want to have a border radius as well. Flutter expects the border to be uniform, i.e. all the way around and in the same color, when applying border radius.
This is the easiest way that I could came up with... as you can see there's 2 container, the color of outer container is actually the color of the border and the margin of inner container is the strokeWidth of the border and the color of inner container is the background color.
Container(
decoration: BoxDecoration(
color: Colors.grey[400],
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(15.0),
topRight: const Radius.circular(15.0),
),// BorderRadius
),// BoxDecoration
child: Container(
margin: const EdgeInsetsDirectional.only(start: 2, end: 2, top: 2),
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(13.0),
topRight: const Radius.circular(13.0),
),// BorderRadius
),// BoxDecoration
),// Container
),// Container
It's a bit silly answer but works! ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With