Flutter android equivalent of scaleX and scaleY property

Viewed 2069

In Android, I can use scaleX and scaleY property but in Flutter I can't find anything like that.

There is Transform.scale() but it combines both scaleX and scaleY and what I need is just scaleX. I know Perspective can help but it's too much for just scaleX property. Anyone with better answer?

1 Answers

the easiest way is to see how Transform.scale constructor works and use it in your custom Transform:

Transform.scale({
     Key key,
     @required double scale,
     this.origin,
     this.alignment = Alignment.center,
     this.transformHitTests = true,
     Widget child,
   }) : transform = Matrix4.diagonal3Values(scale, scale, 1.0),
       super(key: key, child: child);

it scales both x and y so if you want only x axis to be scaled just use the following:

Transform(
  transform: Matrix4.diagonal3Values(scale, 1.0, 1.0),
  child: ....,)
Related