57 lines
1.5 KiB
Dart
57 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:star_lock/tools/titleAppBar.dart';
|
|
import 'package:webview_flutter/webview_flutter.dart';
|
|
|
|
class WebviewShowPage extends StatefulWidget {
|
|
const WebviewShowPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<WebviewShowPage> createState() => _WebviewShowPageState();
|
|
}
|
|
|
|
class _WebviewShowPageState extends State<WebviewShowPage> {
|
|
late WebViewController _webViewController;
|
|
String _webURL = '';
|
|
String _webTitle = '';
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_webViewController = WebViewController()
|
|
..setJavaScriptMode(JavaScriptMode.unrestricted);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
|
if (obj != null && (obj["url"] != null)) {
|
|
_webURL = obj["url"];
|
|
}
|
|
|
|
if (obj != null && (obj["title"] != null)) {
|
|
_webTitle = obj["title"];
|
|
}
|
|
|
|
_webViewController.loadRequest(Uri.parse(_webURL));
|
|
return Scaffold(
|
|
resizeToAvoidBottomInset: false,
|
|
backgroundColor: const Color(0xFFFFFFFF),
|
|
appBar: TitleAppBar(
|
|
barTitle: getWebTitle(),
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor,
|
|
),
|
|
body: WebViewWidget(controller: _webViewController));
|
|
}
|
|
|
|
String getWebTitle() {
|
|
String webTitleStr = _webTitle;
|
|
_webViewController.getTitle().then((result) {
|
|
webTitleStr = result!;
|
|
});
|
|
return webTitleStr;
|
|
}
|
|
}
|