gpt4 book ai didi

android - Flutter:让 iFame 在 Android 设备上全屏显示

转载 作者:行者123 更新时间:2023-12-05 00:05:14 27 4
gpt4 key购买 nike

我正在尝试使用 webview_flutter 加载 iFrame。我无法在 Android 上全屏显示视频。它在 iOS 上运行良好。

这是我的设置。
webview_flutter: 0.3.18+1

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
runApp(MaterialApp(
title: 'IFrameTest',
home: IFrameDemo(),
));
}

class IFrameDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Iframe'),
),
body: Center(
child: Container(
child: WebView(
initialUrl: Uri.dataFromString(
'<html><body><iframe width="300" height="200" src="http://player.youku.com/embed/XODY3NDMzNjY4" allowfullscreen></iframe></body></html>',
mimeType: 'text/html').toString(),
javascriptMode: JavascriptMode.unrestricted,
)),
),
);
}
}

当我点击右下角的全屏按钮时,会出现以下错误:

2020-03-02 11:50:38.411 7845-7845/com.example.helloiframe E/InputMethodManager: b/117267690: Failed to get fallback IMM with expected displayId=1 actual IMM#displayId=0 view=io.flutter.plugins.webviewflutter.InputAwareWebView{4981903 VFEDHVC.. .F...... 0,0-1080,1840}

最佳答案

使用flutter_inappwebview


这是一个示例代码

import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

Future main() async {
WidgetsFlutterBinding.ensureInitialized();

runApp(MaterialApp(home: new MyApp()));
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Sample")),
body: SizedBox(
height: 250,
child: InAppWebView(
initialData: InAppWebViewInitialData(
data: 'YOUR IFRAME'
),
),
),
);
}
}

关于android - Flutter:让 iFame 在 Android 设备上全屏显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60482424/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com