I am using using the Perspectives Pageview library in Flutter to implement a horizontal carousel. Everything works fine when I am just rendering regular Containers
with images or text, etc.
However, when I embed a WebView, it overflows beyond its parent Container, and resizes upon moving the Widget around:
I am unsure of what causes this and how I may fix it so that it stays inside the parent, like other elements.
My code:
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)])))
I have also tried replacing the Expanded
parent of the WebView
with
Container(
width: 300,
height: 200,
child: WebViewPlus(
...
and I encounter the same issue. Upon horizontally scrolling the carousel, the WebView size changes, unlike other content contained within the Carousel.
Many thanks for any insight.