import 'package:flutter/material.dart'; import 'package:sport/services/app_subscription_state.dart'; import 'package:sport/widgets/appbar.dart'; import 'package:webview_flutter/webview_flutter.dart'; class WebPage extends StatefulWidget { final String url; const WebPage({Key? key, required this.url}) : super(key: key); @override State createState() => _PageState(); } class _PageState extends State with SubscriptionState { WebViewController? _controller; int _onPageProgress = 0; @override void initState() { super.initState(); } @override void dispose() { _controller = null; super.dispose(); } _js(String call) { _controller?.evaluateJavascript("javascript:if(window.SHOES_SDK != undefined && window.SHOES_SDK != null) window.SHOES_SDK.$call"); } @override Widget build(BuildContext context) { String url = widget.url; return Scaffold( appBar: buildAppBar(context), body: Stack( fit: StackFit.expand, children: [ WebView( initialUrl: url, javascriptMode: JavascriptMode.unrestricted, onWebViewCreated: (WebViewController webViewController) { _controller = webViewController; }, onProgress: (progress) { setState(() { _onPageProgress = progress; }); }, onPageFinished: (r) {}, ), if (_onPageProgress < 100.0) Positioned( top: 0, right: 0, left: 0, child: SizedBox( height: 5, child: LinearProgressIndicator( value: _onPageProgress / 100.0, ))), ], ), ); } }