How do I apply a ClipPath to a BottomBar or a BottomNavigationBar in Flutter? I am trying to clip around the fourth tab in BottomBar(The clipped path should always be around fourth element). This is what I have so far:
#override
getClip(Size size) {
Path path = Path();
path.lineTo(0, size.height);
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0);
path.lineTo(size.width * 0.79, 0);
path.quadraticBezierTo(size.width*0.77, 0, size.width*0.77, size.height*0.2);
path.cubicTo(size.width * 0.77, size.height*1.2, size.width * 0.61, size.height*1.2,
size.width * 0.61, size.height*0.2);
path.quadraticBezierTo(size.width*0.61, 0, size.width*0.60,0);
path.lineTo(size.width * 0.59, 0);
return path;
}
#override
bool shouldReclip(CustomClipper oldClipper) {
return false;
}
}
WHAT I WANT:
The fourth element needs to be within the Center of the ClipPath for all screen sizes within a Stack.
Thanks!
Related
I am searching for a package in flutter where I can create a chart with an interactable graph, where I can manipulate data with drag and drop
Example:
An example chart
Now I want to ajust each value in that step diagram with drag and drop (up and down)
I found high charts and some of my collegues used that to do so but not in flutter so im not sure if that is possible there.
Firstly, It's totally possible to create interactive charts with Flutter.
You can either implement it yourself with a CustomPainter and some widgets.
Here's an example of a Curved basic chart.
CustomPaint(
painter: CurveBackground(color: \\ yourColor),
child: \\ your child
)
class CurveBackground extends CustomPainter {
final Color color;
CurveBackground({this.color});
#override
void paint(Canvas canvas, Size size) {
var paint = Paint();
paint.color = color;
paint.style = PaintingStyle.fill;
var path = Path();
path.moveTo(0, Dimens.size_30());
path.quadraticBezierTo(size.width * 0.4, size.height * 0.1,
size.width * 0.3, size.height * 0.3);
path.quadraticBezierTo(size.width * 0.1, size.height * 0.6,
size.width * 0.45, size.height * 0.7);
path.quadraticBezierTo(
size.width * 1, size.height * 0.9, size.width * 0.9, size.height * 1.0);
path.lineTo(size.width, size.height);
path.lineTo(0, size.height);
canvas.drawPath(path, paint);
}
#override
bool shouldRepaint(CustomPainter oldDelegate) => true;
}
You can also check out some specialized packages as: syncfusion_flutter_charts
I think you'll be interested in the step_line chart.
Path I am trying to achieve
I had been trying to achieve this path, but I am having trouble when clipping, not only it clips the opposite part of the container but also gets my path to be dirty.
I am also looking on achieving the same effect, but with an opposite direction.
This is the code i have done so far(It is an up arc clip path):
class UpArcClip extends CustomClipper<Path> {
#override
Path getClip(Size size) {
final path = Path();
path.lineTo(0, size.height);
path.lineTo(0.0, size.height - 100);
path.quadraticBezierTo(
size.width / 2, size.height, size.width, size.height - 100);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
#override
bool shouldReclip(CustomClipper old) => false;
}
Already achieved it by myself:
class LeftInclinedArcClipper extends CustomClipper<Path> {
#override
Path getClip(Size size) {
final path = Path();
path.moveTo(0, size.height);
path.lineTo(0, size.height * 0.7);
path.quadraticBezierTo(
size.width / 3, size.height * 0.45, size.width, size.height * 0.53);
path.lineTo(size.width, size.height);
path.close();
return path;
}
#override
bool shouldReclip(CustomClipper old) => false;
}
How can I make my corners rounded in a Path for ClipPath?
class MyClipper extends CustomClipper<Path> {
#override
Path getClip(Size size) {
final Path path = Path();
path.moveTo(0, 0);
path.lineTo(size.width - 10, 0);
path.lineTo(size.width, size.height / 2);
path.lineTo(size.width - 10, size.height);
path.lineTo(0, size.height);
path.lineTo(0, 0);
path.close();
return path;
}
#override
bool shouldReclip(MyClipper oldClipper) => false;
}
I tried adding this in the middle but it didn't give the desired results
path.quadraticBezierTo(size.width - radius, size.height / 2 - radius, size.width + radius, size.height / 2 + radius);
Trying to round this part
Draw the black part of this first:
And then replace the lineTo between the black arrows with the bezier method using the control point
Example how to use the quadraticBezierTo method:
path.moveTo(0, 0);
final controlPoint = Offset(1, 1);
path.quadraticBezierTo(controlPoint.dx, controlPoint.dy, 0, 2);
path.lineTo(0, 0);
This draws half an oval.
I am currently unable to draw a bezier curve.
The output I have right now is :
The output that I need is :
What should I add here as bezier values to get the curve?
The code snippet of the custom clipper is:
class OnBoardingClipper extends CustomClipper<Path> {
#override
Path getClip(Size size) {
var path = Path();
path.moveTo(0.0, size.height * 0.18);
path.lineTo(0.0, size.height);
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0.0);
return path;
}
#override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
P.S. Thanks for reading and apologies in case of bad formatting. :-)
You can add a quadraticBezier with values of e.g., (3 / 4 * size.width, size.height * 0.18) , (size.width, size.height * 0.05).
Code:
#override
Path getClip(Size size) {
var path = Path();
path.moveTo(0.0, size.height * 0.18);
path.quadraticBezierTo(
3 / 4 * size.width, size.height * 0.18, size.width, size.height * 0.05);
path.lineTo(size.width, size.height);
path.lineTo(0.0, size.height);
return path;
}
Result:
I need to implement below like effect on top of image slider, please guide me
You can create custom ClipPath
class Clipper extends CustomClipper<Path> {
#override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0, size.height);
path.quadraticBezierTo(
size.width / 4, size.height - 40, size.width / 2, size.height - 20);
path.quadraticBezierTo(
3 / 4 * size.width, size.height, size.width, size.height - 30);
path.lineTo(size.width, 0);
return path;
}
#override
bool shouldReclip(Clipper oldClipper) => false;
}
find sample snippet
Note : this is basic idea you to have modify by your own requirement
sample output