当前位置:网站首页>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);
},
),
);
边栏推荐
- Maidong Internet won the bid of Beijing life insurance
- MYSQL 用!=查询不出等于null的数据,解决办法
- 【活动早知道】LiveVideoStack近期活动一览
- Jerry's ad series MIDI function description [chapter]
- HWiNFO硬件检测工具v7.26绿色版
- Minidom module writes and parses XML
- 杰理之AD 系列 MIDI 功能说明【篇】
- Gobang go to work fishing tools can be LAN / man-machine
- Delphi SOAP WebService 服务器端多个 SoapDataModule 实现相同的接口方法,接口继承
- redis事务
猜你喜欢
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??
torch. Tensor and torch The difference between tensor
Foxit pdf editor v10.1.8 green version
Configuration of DNS server of Huawei ENSP simulator
B站视频 声音很小——解决办法
The video sound of station B is very low - solution
What are the functional modules of RFID warehouse management system solution
五子棋 上班摸鱼工具 可局域网/人机
巅峰不止,继续奋斗!城链科技数字峰会于重庆隆重举行
奋斗正当时,城链科技战略峰会广州站圆满召开
随机推荐
数十亿公民信息遭泄漏!公有云上的数据安全还有“救”吗?
redis发布订阅的使用
【公开课预告】:视频质量评价基础与实践
Test case (TC)
Roast B station charges, is it because it has no money?
minidom 模塊寫入和解析 XML
【微信小程序】协同工作与发布
Flutter在 release版本,打开后随机白屏不显示内容
Actual combat simulation │ JWT login authentication
Maya lamp modeling
华为ensp模拟器 DNS服务器的配置
Redis transaction
Delphi SOAP WebService 服务器端多个 SoapDataModule 实现相同的接口方法,接口继承
Foxit pdf editor v10.1.8 green version
【C語言】符號的深度理解
MYSQL 用!=查询不出等于null的数据,解决办法
Huawei ENSP simulator layer 3 switch
redis RDB AOF
Redis pipeline
[Shenbo introduction] VI How to contact your favorite doctoral tutor