Files
ln-ios/ln_jq_app/lib/pages/c_page/map/view.dart
2025-11-24 14:49:07 +08:00

48 lines
1.3 KiB
Dart

import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'controller.dart';
class MapPage extends GetView<MapController> {
const MapPage({super.key});
Widget _buildView() {
return Stack(
children: [
InAppWebView(
// 确保 pubspec.yaml 中声明了 assets/html/map.html
initialFile: 'assets/html/map.html',
initialSettings: InAppWebViewSettings(
isInspectable: true,
geolocationEnabled: true,
// 允许 JS 弹窗 (Alert) 用于调试
javaScriptCanOpenWindowsAutomatically: true,
),
onWebViewCreated: (c) {
controller.webViewController = c;
},
onLoadStop: (c, url) {
// 通知 Controller 页面加载完毕
controller.onWebViewLoadStop();
},
onConsoleMessage: (controller, consoleMessage) {
// 方便在 Flutter 控制台看 JS 日志
print("JS Log: ${consoleMessage.message}");
},
),
],
);
}
@override
Widget build(BuildContext context) {
return GetBuilder<MapController>(
init: MapController(),
id: 'map',
builder: (_) {
return _buildView();
},
);
}
}