diff --git a/lib/widgets/buttons/neopop_button/neopop_button_clippers.dart b/lib/widgets/buttons/neopop_button/neopop_button_clippers.dart index 6dde0d2..4657073 100644 --- a/lib/widgets/buttons/neopop_button/neopop_button_clippers.dart +++ b/lib/widgets/buttons/neopop_button/neopop_button_clippers.dart @@ -13,12 +13,16 @@ class RBottomCenterClipper extends CustomClipper { final double depth; @override Path getClip(Size size) => Path() - ..moveTo(0, 0) - ..lineTo(0, size.height + depth) - ..lineTo(size.width + depth, size.height + depth) - ..lineTo(size.width, size.height) - ..lineTo(size.width, 0) - ..close(); + ..addPolygon( + [ + Offset.zero, + Offset(0, size.height + depth), + Offset(size.width + depth, size.height + depth), + Offset(size.width, size.height), + Offset(size.width, 0), + ], + true, + ); @override bool shouldReclip(covariant CustomClipper oldClipper) => false; @@ -31,13 +35,17 @@ class RBottomRightClipper extends CustomClipper { final double depth; @override Path getClip(Size size) => Path() - ..moveTo(0, 0) - ..lineTo(0, size.height) - ..lineTo(0 + depth, size.height + depth) - ..lineTo(size.width + depth, size.height + depth) - ..lineTo(size.width + depth, depth) - ..lineTo(size.width, 0) - ..close(); + ..addPolygon( + [ + Offset.zero, + Offset(0, size.height), + Offset(0 + depth, size.height + depth), + Offset(size.width + depth, size.height + depth), + Offset(size.width + depth, depth), + Offset(size.width, 0), + ], + true, + ); @override bool shouldReclip(covariant CustomClipper oldClipper) => false; @@ -49,13 +57,17 @@ class RBottomLeftClipper extends CustomClipper { final double depth; @override Path getClip(Size size) => Path() - ..moveTo(0, 0) - ..lineTo(0, size.height) - ..lineTo(0 + depth, size.height + depth) - ..lineTo(size.width + depth, size.height + depth) - ..lineTo(size.width, size.height) - ..lineTo(size.width, 0) - ..close(); + ..addPolygon( + [ + Offset.zero, + Offset(0, size.height), + Offset(0 + depth, size.height + depth), + Offset(size.width + depth, size.height + depth), + Offset(size.width, size.height), + Offset(size.width, 0), + ], + true, + ); @override bool shouldReclip(covariant CustomClipper oldClipper) => false; @@ -69,13 +81,17 @@ class RTopRightClipper extends CustomClipper { @override Path getClip(Size size) => Path() - ..moveTo(0, 0) - ..lineTo(0, size.height) - ..lineTo(size.width, size.height) - ..lineTo(size.width + depth, size.height + depth) - ..lineTo(size.width + depth, depth) - ..lineTo(size.width, 0) - ..close(); + ..addPolygon( + [ + Offset.zero, + Offset(0, size.height), + Offset(size.width, size.height), + Offset(size.width + depth, size.height + depth), + Offset(size.width + depth, depth), + Offset(size.width, 0), + ], + true, + ); @override bool shouldReclip(covariant CustomClipper oldClipper) => false; @@ -89,11 +105,15 @@ class CenterClipper extends CustomClipper { @override Path getClip(Size size) => Path() - ..moveTo(0, 0) - ..lineTo(0, size.height) - ..lineTo(size.width, size.height) - ..lineTo(size.width, 0) - ..close(); + ..addPolygon( + [ + Offset.zero, + Offset(0, size.height), + Offset(size.width, size.height), + Offset(size.width, 0), + ], + true, + ); @override bool shouldReclip(covariant CustomClipper oldClipper) => false; diff --git a/lib/widgets/buttons/neopop_button/neopop_button_painter.dart b/lib/widgets/buttons/neopop_button/neopop_button_painter.dart index e4a8138..3149969 100644 --- a/lib/widgets/buttons/neopop_button/neopop_button_painter.dart +++ b/lib/widgets/buttons/neopop_button/neopop_button_painter.dart @@ -39,10 +39,15 @@ class NeoPopButtonPainter extends CustomPainter { if (right != Colors.transparent) { canvas.drawPath( Path() - ..moveTo(size.width, 0) - ..lineTo(size.width + depth, depth) - ..lineTo(size.width + depth, size.height + depth) - ..lineTo(size.width, size.height), + ..addPolygon( + [ + Offset(size.width, 0), + Offset(size.width + depth, depth), + Offset(size.width + depth, size.height + depth), + Offset(size.width, size.height), + ], + true, + ), Paint() ..style = PaintingStyle.fill ..color = right @@ -54,10 +59,15 @@ class NeoPopButtonPainter extends CustomPainter { if (left != Colors.transparent) { canvas.drawPath( Path() - ..moveTo(0, 0) - ..lineTo(-depth, -depth) - ..lineTo(-depth, size.height - depth) - ..lineTo(0, size.height), + ..addPolygon( + [ + Offset.zero, + Offset(-depth, -depth), + Offset(-depth, size.height - depth), + Offset(0, size.height), + ], + true, + ), Paint() ..style = PaintingStyle.fill ..color = left @@ -69,10 +79,15 @@ class NeoPopButtonPainter extends CustomPainter { if (bottom != Colors.transparent) { canvas.drawPath( Path() - ..moveTo(size.width, size.height) - ..lineTo(size.width + depth, size.height + depth) - ..lineTo(0 + depth, size.height + depth) - ..lineTo(0, size.height), + ..addPolygon( + [ + Offset(size.width, size.height), + Offset(size.width + depth, size.height + depth), + Offset(depth, size.height + depth), + Offset(0, size.height), + ], + true, + ), Paint() ..style = PaintingStyle.fill ..color = bottom @@ -84,10 +99,12 @@ class NeoPopButtonPainter extends CustomPainter { if (top != Colors.transparent) { canvas.drawPath( Path() - ..moveTo(0, 0) - ..lineTo(-depth, -depth) - ..lineTo(size.width - depth, -depth) - ..lineTo(size.width, 0), + ..addPolygon([ + Offset.zero, + Offset(-depth, -depth), + Offset(size.width - depth, -depth), + Offset(size.width, 0), + ], true), Paint() ..style = PaintingStyle.fill ..color = top diff --git a/lib/widgets/cards/neopop_card.dart b/lib/widgets/cards/neopop_card.dart index e17696f..55b8121 100644 --- a/lib/widgets/cards/neopop_card.dart +++ b/lib/widgets/cards/neopop_card.dart @@ -5,6 +5,8 @@ // You may obtain a copy of the License in the LICENSE file or at // http://www.apache.org/licenses/LICENSE-2.0 +import 'dart:ui'; + import 'package:flutter/material.dart'; import 'package:neopop/utils/color_utils.dart'; import 'package:neopop/utils/constants.dart'; diff --git a/lib/widgets/cards/neopop_card_painter.dart b/lib/widgets/cards/neopop_card_painter.dart index a04ef49..5eecb22 100644 --- a/lib/widgets/cards/neopop_card_painter.dart +++ b/lib/widgets/cards/neopop_card_painter.dart @@ -27,10 +27,15 @@ class NeoPopCardPainter extends CustomPainter { canvas ..drawPath( Path() - ..moveTo(size.width, 0) - ..lineTo(size.width + depth, depth) - ..lineTo(size.width + depth, size.height + depth) - ..lineTo(size.width, size.height), + ..addPolygon( + [ + Offset(size.width, 0), + Offset(size.width + depth, depth), + Offset(size.width + depth, size.height + depth), + Offset(size.width, size.height), + ], + true, + ), Paint() ..style = PaintingStyle.fill ..color = hShadowColor ?? Colors.transparent @@ -40,10 +45,15 @@ class NeoPopCardPainter extends CustomPainter { // bottom shadow ..drawPath( Path() - ..moveTo(size.width, size.height) - ..lineTo(size.width + depth, size.height + depth) - ..lineTo(0 + depth, size.height + depth) - ..lineTo(0, size.height), + ..addPolygon( + [ + Offset(size.width, size.height), + Offset(size.width + depth, size.height + depth), + Offset(0 + depth, size.height + depth), + Offset(0, size.height), + ], + true, + ), Paint() ..style = PaintingStyle.fill ..color = vShadowColor ?? Colors.transparent diff --git a/lib/widgets/shimmer/shimmer_painter.dart b/lib/widgets/shimmer/shimmer_painter.dart index 5454ce3..50c29d0 100644 --- a/lib/widgets/shimmer/shimmer_painter.dart +++ b/lib/widgets/shimmer/shimmer_painter.dart @@ -35,11 +35,7 @@ class ShimmerPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final smallShimmerWidth = shimmerWidth / 2; - final double x = (size.width + - (2 * shimmerWidth) + - shimmerGapWidth + - smallShimmerWidth) * - offset; + final double x = (size.width + (2 * shimmerWidth) + shimmerGapWidth + smallShimmerWidth) * offset; final double y = size.height; if (!isTiltedLeft) { @@ -55,21 +51,29 @@ class ShimmerPainter extends CustomPainter { canvas.drawPath( Path() - ..moveTo(x1, y) - ..lineTo(x2, 0) - ..lineTo(x3, 0) - ..lineTo(x4, y) - ..close(), + ..addPolygon( + [ + Offset(x1, y), + Offset(x2, 0), + Offset(x3, 0), + Offset(x4, y), + ], + true, + ), Paint()..color = shimmerColor, ); canvas.drawPath( Path() - ..moveTo(x5, y) - ..lineTo(x6, 0) - ..lineTo(x7, 0) - ..lineTo(x8, y) - ..close(), + ..addPolygon( + [ + Offset(x5, y), + Offset(x6, 0), + Offset(x7, 0), + Offset(x8, y), + ], + true, + ), Paint()..color = shimmerColor, ); } else { @@ -85,21 +89,29 @@ class ShimmerPainter extends CustomPainter { canvas.drawPath( Path() - ..moveTo(x1, y) - ..lineTo(x2, 0) - ..lineTo(x3, 0) - ..lineTo(x4, y) - ..close(), + ..addPolygon( + [ + Offset(x1, y), + Offset(x2, 0), + Offset(x3, 0), + Offset(x4, y), + ], + true, + ), Paint()..color = shimmerColor, ); canvas.drawPath( Path() - ..moveTo(x5, y) - ..lineTo(x6, 0) - ..lineTo(x7, 0) - ..lineTo(x8, y) - ..close(), + ..addPolygon( + [ + Offset(x5, y), + Offset(x6, 0), + Offset(x7, 0), + Offset(x8, y), + ], + true, + ), Paint()..color = shimmerColor, ); }