我正在使用 Flutter 中的Perspectives Pageview库来实现水平轮播。当我只是Containers
用图像或文本等进行常规渲染时,一切正常。
但是,当我嵌入 WebView 时,它会溢出其父容器,并在移动 Widget 时调整大小:
我不确定是什么原因造成的,以及如何修复它,以便它像其他元素一样留在父元素中。
我的代码:
Container(
child: Center(
// Adding Child Widget of Perspective PageView
child: PerspectivePageView(
hasShadow: true, // Enable-Disable Shadow
shadowColor: Colors.black12,
children: <Widget>[
Container(
child: Column(
children: [
Expanded(
child: Container(
color: Colors.black54,
child: Container(
color: Colors.white,
child: Column(
children: [
Expanded(
child: WebViewPlus(
onWebViewCreated: (controller) {
this._controller = controller;
controller
.loadString(_htmlForCardsList[0]);
},
javascriptMode: JavascriptMode.unrestricted,
),
)
],
)),
padding: EdgeInsets.all(2),
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"View Next",
style: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.w400,
color: Colors.orange),
),
],
),
height: 60,
decoration: BoxDecoration(
color: Colors.white,
border: Border(
top: BorderSide(color: Colors.black54, width: .3),
bottom: BorderSide(color: Colors.black54, width: 1.5),
left: BorderSide(color: Colors.black54, width: 1.5),
right: BorderSide(color: Colors.black54, width: 1.5),
),
),
),
],
),
color: Colors.orange)])))
我也尝试Expanded
过WebView
用
Container(
width: 300,
height: 200,
child: WebViewPlus(
...
我遇到了同样的问题。水平滚动轮播后,WebView 的大小会发生变化,这与轮播中包含的其他内容不同。
非常感谢您的任何见解。