当前位置:网站首页>Flutter WebView示例
Flutter WebView示例
2022-07-04 20:35:00 【海阔天空6688】
加载url
final Completer<WebViewController> _controller = Completer<WebViewController>();
int _progressValue = 0;
@override
void initState() {
super.initState();
// Enable hybrid composition.
if (Device.isAndroid) {
WebView.platform = SurfaceAndroidWebView();
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
WebView(
initialUrl: "https://www.baidu.com",
javascriptMode: JavascriptMode.unrestricted,
allowsInlineMediaPlayback: true,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
onProgress: (int progress) {
debugPrint('WebView is loading (progress : $progress%)');
setState(() {
_progressValue = progress;
});
},
),
if (_progressValue != 100) LinearProgressIndicator(
value: _progressValue / 100,
backgroundColor: Colors.transparent,
minHeight: 2,
) else Gaps.empty,
],
),
);
}
加载html字符串
String html = """
<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
<body>
<p>html字符串加载</p>
</body>
</html>
""";
return Scaffold(
appBar: AppBar(title: Text(widget.messageItem.title)),
body: WebView(
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController controller) {
controller.loadHtmlString(html);
},
),
);
边栏推荐
- 华为ensp模拟器 配置ACL访问控制列表
- async await 在map中使用
- 2021 CCPC Harbin B. magical subsequence (thinking question)
- Why does invariant mode improve performance
- At the right time, the Guangzhou station of the city chain science and Technology Strategy Summit was successfully held
- 嵌入式TC 测试用例
- Introduction to pressure measurement of JMeter
- 【optimtool.unconstrain】无约束优化工具箱
- colResizable.js自动调整表格宽度插件
- Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation
猜你喜欢
A quick start to fastdfs takes you three minutes to upload and download files to the ECS
Daily question -leetcode1200- minimum absolute difference - array - sort
colResizable.js自动调整表格宽度插件
解析steam教育中蕴含的众创空间
The video sound of station B is very low - solution
IIC (STM32)
MP3是如何诞生的?
【optimtool.unconstrain】无约束优化工具箱
Routing configuration and connectivity test of Huawei simulator ENSP
网件r7000梅林系统虚拟内存创建失败,提示USB磁盘读写速度不满足要求解决办法,有需要创建虚拟内存吗??
随机推荐
旋变串判断
redis RDB AOF
[ 每周译Go ] 《How to Code in Go》系列文章上线了!!
Redis cache
华为模拟器ensp的路由配置以及连通测试
Use of redis publish subscription
Jerry's ad series MIDI function description [chapter]
插入排序,选择排序,冒泡排序
Redis pipeline
NetWare r7000 Merlin system virtual memory creation failed, prompting that the USB disk reading and writing speed does not meet the requirements. Solution, is it necessary to create virtual memory??
MP3是如何诞生的?
杰理之AD 系列 MIDI 功能说明【篇】
Google colab踩坑
Redis transaction
Kubeadm初始化报错:[ERROR CRI]: container runtime is not running
Jerry's ad series MIDI function description [chapter]
render函数与虚拟dom
Jerry's ad series MIDI function description [chapter]
SolidWorks工程图添加材料明细表的操作
Can be displayed in CAD but not displayed in print