0

I have a screen with a PageView, PageView have 3 webView as childs, and pageView scrollDirection is Axis.vertical, the problem is each pageView child height is not adjust to the height of each webView height.

Widget build(BuildContext context) {
final PageController controller = PageController(initialPage: 0);
return PageView(
  /// [PageView.scrollDirection] defaults to [Axis.horizontal].
  /// Use [Axis.vertical] to scroll vertically.
  scrollDirection: Axis.vertical,
  controller: controller,
  children: const <Widget>[
    createWebView("/book/page1.html"),
    createWebView("/book/page2.html"),
    createWebView("/book/page3.html"),
  ],
);

}

Screenshot

How to set the height for each pageView child after load web content completed, thank you!

noname.cs
  • 1,938
  • 4
  • 16
  • 25
  • Have you tried wrapping each child in SizedBox with height set to MediaQuery.of(context).size.height? – Kozimir Sep 23 '21 at 08:41
  • Yes, I did. But the webview only have the contentHeight after content loaded. When I get the contentHeight and assign to height of the SizedBox which wrap webview, call setState to update the screen, but the PageView didnt resize the height of each child page. – noname.cs Sep 23 '21 at 10:03
  • @noname.cs have you found any solution for this? – Abreeth Mar 26 '22 at 17:43

0 Answers0