当前位置:网站首页>Shutter WebView example
Shutter WebView example
2022-07-04 21:32:00 【Boundless 6688】
load 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,
],
),
);
}
load html character string
String html = """
<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
<body>
<p>html String loading </p>
</body>
</html>
""";
return Scaffold(
appBar: AppBar(title: Text(widget.messageItem.title)),
body: WebView(
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController controller) {
controller.loadHtmlString(html);
},
),
);
边栏推荐
猜你喜欢
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??
admas零件名重复
TweenMax表情按钮js特效
Explication détaillée du mécanisme de distribution des événements d'entrée multimodes
PS vertical English and digital text how to change direction (vertical display)
【optimtool.unconstrain】无约束优化工具箱
ApplicationContext 与 BeanFactory 区别(MS)
LambdaQueryWrapper用法
OMS系统实战的三两事
Word文档中标题前面的黑点如何去掉
随机推荐
Daily question -leetcode1200- minimum absolute difference - array - sort
For MySQL= No data equal to null can be found. Solution
Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation
迈动互联中标北京人寿保险
[Shenbo introduction] VI How to contact your favorite doctoral tutor
【Try to Hack】宽字节注入
PS vertical English and digital text how to change direction (vertical display)
每日一题-LeetCode556-下一个更大元素III-字符串-双指针-next_permutation
Jerry's ad series MIDI function description [chapter]
【微服务|SCG】Predicate的使用
colResizable.js自动调整表格宽度插件
Word文档中标题前面的黑点如何去掉
Foxit pdf editor v10.1.8 green version
WGCNA分析基本教程总结
Huawei ENSP simulator layer 3 switch
解析互联网时代的创客教育技术
Use of redis publish subscription
杰理之AD 系列 MIDI 功能说明【篇】
Huawei ENSP simulator configures ACL access control list
Redis bloom filter