You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used your package with latest version but it is giving the same issue which i am facing on webview_flutter: ^4.7.0.
Only on android the height is coming very large but on ios calculation is correct.
here is my code
class _WebviewHtmlTextState extends State {
late final WebViewController _webController;
double? webViewHeight;
@OverRide
void initState() {
super.initState();
// #docregion platform_features
late final PlatformWebViewControllerCreationParams params;
if (WebViewPlatform.instance is WebKitWebViewPlatform) {
params = WebKitWebViewControllerCreationParams(
allowsInlineMediaPlayback: true,
mediaTypesRequiringUserAction: const {},
);
} else {
params = const PlatformWebViewControllerCreationParams();
}
final WebViewController webController =
WebViewController.fromPlatformCreationParams(params);
if (webController.platform is AndroidWebViewController) {
(webController.platform as AndroidWebViewController)
.setMediaPlaybackRequiresUserGesture(true);
}
webController
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(Color(0xffF5FAFF))
..loadRequest(Uri.dataFromString(
IhwUtils.addMetaInHead(widget.htmlText!),
mimeType: 'text/html',
encoding: Encoding.getByName('utf-8'))
,)
..addJavaScriptChannel('messageHandler',
onMessageReceived: (JavaScriptMessage message) async {
print('message from the web view=\"${message.message}\"');
})
..setNavigationDelegate(
NavigationDelegate(
onNavigationRequest: (request) {
if (request.url.startsWith('https://www.youtube.com/')) {
Get.toNamed<dynamic>(Routes.YOUTUBE_PLAYER.routePath,
arguments: request.url);
return NavigationDecision.prevent;
} else if (Uri.tryParse(request.url)?.hasAbsolutePath ?? false) {
Get.toNamed<dynamic>(Routes.WEB_VIEW.name, parameters: {
'web_url': request.url,
'title': '',
'landscape': 'false',
'fullscreen': 'false'
});
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
onPageFinished: (String url) async {
// Add some delay before evaluate
await Future<dynamic>.delayed(const Duration(milliseconds: 500));
var _height = await webController.runJavaScriptReturningResult(
'document.body.offsetHeight;');
setState(() {
webViewHeight = (_height as num).toDouble();
});
},
),
);
_webController = webController;
}
class IhwUtils {
// add meta tag in head tag of html for ios
static String addMetaInHead(String htmlString) {
I used your package with latest version but it is giving the same issue which i am facing on webview_flutter: ^4.7.0.
Only on android the height is coming very large but on ios calculation is correct.
here is my code
class _WebviewHtmlTextState extends State {
late final WebViewController _webController;
double? webViewHeight;
@OverRide
void initState() {
super.initState();
// #docregion platform_features
late final PlatformWebViewControllerCreationParams params;
if (WebViewPlatform.instance is WebKitWebViewPlatform) {
params = WebKitWebViewControllerCreationParams(
allowsInlineMediaPlayback: true,
mediaTypesRequiringUserAction: const {},
);
} else {
params = const PlatformWebViewControllerCreationParams();
}
}
class IhwUtils {
// add meta tag in head tag of html for ios
static String addMetaInHead(String htmlString) {
}
}
The text was updated successfully, but these errors were encountered: