mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 09:54:19 +01:00
44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
|
import 'package:nowser/component/webview/web_info.dart';
|
|
|
|
class WebViewComponent extends StatefulWidget {
|
|
WebInfo webInfo;
|
|
|
|
Function(WebInfo, InAppWebViewController) onWebViewCreated;
|
|
|
|
Function(WebInfo, InAppWebViewController, String?) onTitleChanged;
|
|
|
|
WebViewComponent(
|
|
this.webInfo,
|
|
this.onWebViewCreated,
|
|
this.onTitleChanged,
|
|
);
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _WebViewComponent();
|
|
}
|
|
}
|
|
|
|
class _WebViewComponent extends State<WebViewComponent> {
|
|
InAppWebViewController? webViewController;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
child: InAppWebView(
|
|
initialUrlRequest: URLRequest(url: WebUri(widget.webInfo.url)),
|
|
onWebViewCreated: (controller) async {
|
|
webViewController = controller;
|
|
// initJSHandle(controller);
|
|
widget.onWebViewCreated(widget.webInfo, controller);
|
|
},
|
|
onTitleChanged: (controller, title) {
|
|
widget.onTitleChanged(widget.webInfo, controller, title);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|