Skip to content

Commit ee86543

Browse files
committed
Fix image scaling issue with alignment overlay.
1 parent 0b649f1 commit ee86543

File tree

1 file changed

+47
-22
lines changed

1 file changed

+47
-22
lines changed

lib/src/transformers/node_transformers/passive_rectangle_transformer.dart

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,17 @@ List<Widget> buildStrokes(
370370
return strokeWidgets;
371371
}
372372

373+
typedef ImageFillBuilder = Widget Function(
374+
String url,
375+
BoxFit fit,
376+
Alignment alignment,
377+
double scale,
378+
double width,
379+
double height,
380+
ImageRepeat repeat,
381+
PaintModel paint,
382+
);
383+
373384
List<Widget> buildFills(
374385
BuildContext context,
375386
BaseNode node,
@@ -378,6 +389,7 @@ List<Widget> buildFills(
378389
double? imageOpacity,
379390
double? imageRotation,
380391
bool isActive = false,
392+
ImageFillBuilder? imageFillBuilder,
381393
}) {
382394
if (node is! GeometryMixin) return [];
383395

@@ -431,28 +443,41 @@ List<Widget> buildFills(
431443
final double scale = paint.scale;
432444
final ImageRepeat repeat = paint.imageRepeat.flutterImageRepeat;
433445

434-
Widget child = bytes != null
435-
? Image.memory(
436-
bytes,
437-
fit: fit,
438-
alignment: alignment ?? Alignment.center,
439-
scale: scale.abs(),
440-
width: node.basicBoxLocal.width,
441-
height: node.basicBoxLocal.height,
442-
repeat: repeat,
443-
)
444-
: _NetworkImageWithStates(
445-
url: imageURL,
446-
fit: fit,
447-
alignment: alignment ?? Alignment.center,
448-
scale: scale.abs(),
449-
width: node.basicBoxLocal.width,
450-
height: node.basicBoxLocal.height,
451-
repeat: repeat,
452-
paint: paint,
453-
node: node,
454-
isActive: isActive,
455-
);
446+
Widget child;
447+
if (bytes != null) {
448+
child = Image.memory(
449+
bytes,
450+
fit: fit,
451+
alignment: alignment ?? Alignment.center,
452+
scale: scale.abs(),
453+
width: node.basicBoxLocal.width,
454+
height: node.basicBoxLocal.height,
455+
repeat: repeat,
456+
);
457+
} else if (imageFillBuilder != null) {
458+
child = imageFillBuilder(
459+
imageURL,
460+
fit,
461+
alignment ?? Alignment.center,
462+
scale,
463+
node.basicBoxLocal.width,
464+
node.basicBoxLocal.height,
465+
repeat,
466+
paint);
467+
} else {
468+
child = _NetworkImageWithStates(
469+
url: imageURL,
470+
fit: fit,
471+
alignment: alignment ?? Alignment.center,
472+
scale: scale.abs(),
473+
width: node.basicBoxLocal.width,
474+
height: node.basicBoxLocal.height,
475+
repeat: repeat,
476+
paint: paint,
477+
node: node,
478+
isActive: isActive,
479+
);
480+
}
456481

457482
child = Transform.scale(
458483
scaleX: paint.isFlippedX ? -1 : 1,

0 commit comments

Comments
 (0)