import 'dart:io'; import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; class WebViewer extends StatefulWidget { final String book_id; const WebViewer({super.key, required this.book_id}); @override State createState() => _WebViewerState(); } class _WebViewerState extends State { late final WebViewController _controller; bool _loading = true; final String baseUrl = "http://192.168.99.115:8080/#fmt=EPUB&mode=read_book&book_id="; @override void initState() { super.initState(); final fullUrl = baseUrl + widget.book_id; // Controller novo (API 4.x) _controller = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setUserAgent("Mozilla/5.0 (Mobile; Flutter)") ..setNavigationDelegate( NavigationDelegate( onPageFinished: (_) { setState(() { _loading = false; }); }, ), ) ..loadRequest(Uri.parse(fullUrl)); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Leitor Online"), backgroundColor: Colors.cyanAccent, foregroundColor: Colors.black, ), body: Stack( children: [ WebViewWidget(controller: _controller), if (_loading) const Center( child: CircularProgressIndicator(), ), ], ), ); } }