我在 Webview 中显示视频并在 url 中发送视频比例,但视频带有一些左右空白,无法在视频 iFrame 中更改。并且不能给出负边距,所以我使用转换来提供负边距,它仅适用于列表的第一项,不能在右侧给出。
return index % 2 != 0 ? Container(
color:Colors.red,
transform: Matrix4.translationValues(-40, 0, -80),
padding: EdgeInsets.all(2),
child: SizedBox(
height: 140,
width: 230,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return DnaWebViewInterface(
key: webVideoKey[index],
url: getDiamondVideoFileUrl(
lotId,
height: constraints.maxHeight,
width: constraints.maxWidth,
),
);
},
)),
):Container(
color:Colors.green,
padding: EdgeInsets.all(2),
transform: Matrix4.translationValues(-40, 0, -60),
child: SizedBox(
height: 140,
width: 230,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return DnaWebViewInterface(
key: webVideoKey[index],
url: getDiamondVideoFileUrl(
lotId,
height: constraints.maxHeight,
width: constraints.maxWidth,
),
);
},
)),
);
您可以使用
SizedBox
(或其他约束小部件)和 OverflowBox
的组合来允许内部子元素在其中溢出。
举一个例子:
SizedBox(
width: 150, // The actual width you want the widget to appears
child: OverflowBox(
alignment: Alignment.center, // Adjust to your need
maxWidth: double.infinity, // The maximum width you want the inner child to be allowed
child: TheWidgetToCrop(...),
),
)
您可以参阅这篇文章以参考与
OverflowBox
结合使用什么小部件。