mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 09:54:19 +01:00
git init
This commit is contained in:
43
lib/component/webview/webview_component.dart
Normal file
43
lib/component/webview/webview_component.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
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);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user