@@ -669,13 +669,22 @@ void paintImage({
669
669
// as we apply a nine-patch stretch.
670
670
assert (sourceSize == inputSize);
671
671
}
672
+ if (repeat != ImageRepeat .noRepeat && destinationSize == outputSize) {
673
+ // There's no need to repeat the image because we're exactly filling the
674
+ // output rect with the image.
675
+ repeat = ImageRepeat .noRepeat;
676
+ }
672
677
Paint paint = new Paint ()..isAntiAlias = false ;
673
678
if (colorFilter != null )
674
679
paint.colorFilter = colorFilter;
675
680
double dx = (outputSize.width - destinationSize.width) * (alignX ?? 0.5 );
676
681
double dy = (outputSize.height - destinationSize.height) * (alignY ?? 0.5 );
677
682
Point destinationPosition = rect.topLeft + new Offset (dx, dy);
678
683
Rect destinationRect = destinationPosition & destinationSize;
684
+ if (repeat != ImageRepeat .noRepeat) {
685
+ canvas.save ();
686
+ canvas.clipRect (rect);
687
+ }
679
688
if (centerSlice == null ) {
680
689
Rect sourceRect = Point .origin & sourceSize;
681
690
for (Rect tileRect in _generateImageTileRects (rect, destinationRect, repeat))
@@ -684,6 +693,8 @@ void paintImage({
684
693
for (Rect tileRect in _generateImageTileRects (rect, destinationRect, repeat))
685
694
canvas.drawImageNine (image, centerSlice, tileRect, paint);
686
695
}
696
+ if (repeat != ImageRepeat .noRepeat)
697
+ canvas.restore ();
687
698
}
688
699
689
700
/// A background image for a box.
0 commit comments