提交 1c28a7ab authored 作者: shixiaochen's avatar shixiaochen

1、增加JS互调方法showToast;

上级 318e93fc
......@@ -76,7 +76,13 @@ class _ComplaintWebPageState extends State<ComplaintWebPage> {
onMessageReceived: (JavaScriptMessage message) async {
debugPrint(
"JavascriptChannel:method = finishPage message = ${message.message}");
finishPage(message.message);
_finishPage(message.message);
})
..addJavaScriptChannel("showToast",
onMessageReceived: (JavaScriptMessage message) async {
debugPrint(
"JavascriptChannel:method = showToast message = ${message.message}");
_onShowToast(message.message);
})
..setNavigationDelegate(
NavigationDelegate(onPageFinished: _onPageFinished))
......@@ -161,8 +167,8 @@ class _ComplaintWebPageState extends State<ComplaintWebPage> {
final jpg = image.encodeJpg(scaledImage, quality: 90);
final filePath = (await getTemporaryDirectory()).uri.resolve(
'./image_${DateTime.now().microsecondsSinceEpoch}.jpg',
);
'./image_${DateTime.now().microsecondsSinceEpoch}.jpg',
);
final file = await File.fromUri(filePath).create(recursive: true);
await file.writeAsBytes(jpg, flush: true);
debugPrint("file = ${file.uri.toString()}");
......@@ -188,8 +194,13 @@ class _ComplaintWebPageState extends State<ComplaintWebPage> {
}
/// 关闭页面
finishPage(String? msg) {
_finishPage(String? msg) {
debugPrint("finishPage:");
Navigator.pop(context);
}
/// 展示toast
_onShowToast(String? msg) {
ToastUtil.showToast(msg);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论