当前位置:网站首页>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);
},
),
);
边栏推荐
猜你喜欢
Maya lamp modeling
Hwinfo hardware detection tool v7.26 green version
IIC (STM32)
Huawei ENSP simulator realizes communication security (switch)
网件r7000梅林系统5g不稳定 5g信号经常掉线解决方法
巅峰不止,继续奋斗!城链科技数字峰会于重庆隆重举行
PS vertical English and digital text how to change direction (vertical display)
【C语言】符号的深度理解
WGCNA analysis basic tutorial summary
shp数据制作3DTiles白膜
随机推荐
杰理之AD 系列 MIDI 功能说明【篇】
Roast B station charges, is it because it has no money?
Jerry's ad series MIDI function description [chapter]
For MySQL= No data equal to null can be found. Solution
网件r7000梅林系统5g不稳定 5g信号经常掉线解决方法
华为ensp模拟器 配置ACL访问控制列表
torch. Tensor and torch The difference between tensor
Flutter TextField示例
吐槽 B 站收费,是怪它没钱么?
每日一题-LeetCode1200-最小绝对差-数组-排序
数十亿公民信息遭泄漏!公有云上的数据安全还有“救”吗?
admas零件名重复
杰理之增加进关机前把触摸模块关闭流程【篇】
flink1.13 sql基础语法(一)DDL、DML
[public class preview]: basis and practice of video quality evaluation
面试官:说说XSS攻击是什么?
解读创客教育中的各类智能化组织发展
Introduction to pressure measurement of JMeter
What are the functional modules of RFID warehouse management system solution
IIC (STM32)