createBarPath method

Path createBarPath(
  1. Size size,
  2. double progress
)

Implementation

Path createBarPath(Size size, double progress) {
  final Path path = Path();

  if (progress >= 0.0 && progress <= 0.25) {
    var k = ((progress / 0.25) * 100) / 100;
    path.moveTo(0, 0);
    path.quadraticBezierTo(0, 0, size.width * k, 0);
  } else if (progress >= 0.25 && progress <= 0.5) {
    path.moveTo(0, 0);
    path.quadraticBezierTo(0, 0, size.width, 0);

    var k = (((progress - 0.25) / 0.25) * 100) / 100;

    path.moveTo(size.width, 0);
    path.quadraticBezierTo(size.width, 0, size.width, size.height * k);
  } else if (progress >= 0.5 && progress <= 0.75) {
    path.moveTo(0, 0);
    path.quadraticBezierTo(0, 0, size.width, 0);

    path.moveTo(size.width, 0);
    path.quadraticBezierTo(size.width, 0, size.width, size.height);

    var k = (((progress - 0.5) / 0.25) * 100) / 100;

    path.moveTo(size.width, size.height);
    path.quadraticBezierTo(
        size.width, size.height, size.width * (1 - k), size.height);
  } else if (progress >= 0.5 && progress <= 1) {
    path.moveTo(0, 0);
    path.quadraticBezierTo(0, 0, size.width, 0);

    path.moveTo(size.width, 0);
    path.quadraticBezierTo(size.width, 0, size.width, size.height);

    path.moveTo(size.width, size.height);
    path.quadraticBezierTo(size.width, size.height, 0, size.height);

    var k = (((progress - 0.75) / 0.25) * 100) / 100;

    path.moveTo(0, size.height);
    path.quadraticBezierTo(0, size.height, 0, (size.height) * (1 - k));
  } else if (progress > 1) {
    path.moveTo(0, 0);
    path.quadraticBezierTo(0, 0, size.width, 0);

    path.moveTo(size.width, 0);
    path.quadraticBezierTo(size.width, 0, size.width, size.height);

    path.moveTo(size.width, size.height);
    path.quadraticBezierTo(size.width, size.height, 0, size.height);

    path.moveTo(0, size.height);
    path.quadraticBezierTo(0, (size.height), 0, 0);
  } else {
    debugPrint("Path Error");
  }

  return path;
}