44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:webview_flutter/webview_flutter.dart';
|
|
|
|
class KtKtWebViewPage extends StatefulWidget {
|
|
final String url;
|
|
final String? title;
|
|
|
|
const KtKtWebViewPage({super.key, required this.url, this.title});
|
|
|
|
@override
|
|
State<KtKtWebViewPage> createState() => _KtWebViewPageState();
|
|
}
|
|
|
|
class _KtWebViewPageState extends State<KtKtWebViewPage> {
|
|
late final WebViewController _controller;
|
|
bool _isLoading = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = WebViewController()
|
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
|
..setNavigationDelegate(
|
|
NavigationDelegate(
|
|
onPageFinished: (_) => setState(() => _isLoading = false),
|
|
),
|
|
)
|
|
..loadRequest(Uri.parse(widget.url));
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(widget.title ?? '')),
|
|
body: Stack(
|
|
children: [
|
|
WebViewWidget(controller: _controller),
|
|
if (_isLoading) const Center(child: CircularProgressIndicator()),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|