0

I use InAppWebView to display a web content in our app. To ensure that it only takes the necessary space I listen to the onLoadStop callback to then set a SizedBoxs height.

There I try to get the content height:

final height = await controller.getContentHeight();

But it always returns 0.

On iOS I always get the right height.

luckyhandler
  • 10,651
  • 3
  • 47
  • 64

1 Answers1

0

The problem is that Android calls the onPageFinished callback for the Android Webview too early. Answer found here.

Adding

if (Platform.isAndroid) {
   await Future.delayed(
      const Duration(milliseconds: 1000),
   );
}

solves the problem and

final height = await controller.getContentHeight();

returns the correct height.

luckyhandler
  • 10,651
  • 3
  • 47
  • 64