'How can I make this not happen in the right and left corners?
How can I make this not happen in the right and left corners? I am radiusing the corners with fromLTRBAndCorners. However, it breaks down while browsing the menu.
..lineTo(size.width, 0)
..lineTo(size.width, size.height)
..lineTo(0, size.height)
..addRect(Rect.fromPoints(const Offset(0, 100), Offset(size.width, 0)))
..addRRect(RRect.fromLTRBAndCorners(
0,
0,
size.width.toDouble(),
size.height.toDouble(),
topLeft: const Radius.circular(50.0),
topRight: const Radius.circular(50.0),
bottomLeft: Radius.zero,
bottomRight: Radius.zero,
))
..fillType = PathFillType.evenOdd
..close();
canvas.drawPath(path, paint);
Solution 1:[1]
all code
late double loc;
late double s;
Color color;
TextDirection textDirection;
NavCustomPainter(double startingLoc, int itemsLength, this.color, this.textDirection) {
final span = 1.0 / itemsLength;
s = 0.2;
double l = startingLoc + (span - s) / 2;
loc = textDirection == TextDirection.rtl ? 0.8 - l : l;
}
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = const Color.fromARGB(255, 87, 192, 241)
..style = PaintingStyle.fill
..maskFilter = MaskFilter.blur(BlurStyle.outer, convertRadiusToSigma(5));
final path = Path()
..moveTo(0, 0)
..lineTo((loc - 0.1) * size.width, 0)
..cubicTo(
(loc + s * 0.20) * size.width,
size.height * 0.05,
loc * size.width,
size.height * 0.60,
(loc + s * 0.50) * size.width,
size.height * 0.60,
)
..cubicTo(
(loc + s) * size.width,
size.height * 0.60,
(loc + s - s * 0.20) * size.width,
size.height * 0.05,
(loc + s + 0.1) * size.width,
0,
)
..lineTo(size.width, 0)
..lineTo(size.width, size.height)
..lineTo(0, size.height)
..addRect(Rect.fromPoints(const Offset(0, 100), Offset(size.width, 0)))
..addRRect(RRect.fromLTRBAndCorners(
0,
0,
size.width.toDouble(),
size.height.toDouble(),
topLeft: const Radius.circular(50.0),
topRight: const Radius.circular(50.0),
bottomLeft: Radius.zero,
bottomRight: Radius.zero,
))
..fillType = PathFillType.evenOdd
..close();
canvas.drawPath(path, paint);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

