当缩放到0.5时,为什么扑动剪辑孩子?



对于比横向屏幕大的小部件场景,我需要根据设备旋转应用不同的比例。

但是当我用0.5的刻度时,孩子们就被剪掉了。

我应该怎么做,缩放到0.5的场景是可见的整个屏幕上?

/// The scene: the hill, the street and the pump
Widget scene() {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
final bool isLandscape = width > height;
final double scale = isLandscape ? 0.5 : 1;
return // == The custom paint sky
Transform.scale(
scale: scale,
child: Stack(
children: [
Positioned(top: 0, width: 150, child: HillVehicleAnimation()),

实际上,默认情况下,Stack()剪辑子节点。因此添加clipBehavior属性并将其设置为Clip.none,以获得所需的效果,如下所示:

return // == The custom paint sky
Transform.scale(
scale: scale,
child: Stack(
// == Ask Stack not to clip!
clipBehavior: Clip.none,
children: [
Positioned(top: 0, width: 150, child: HillVehicleAnimation()),

最新更新