import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:remixicon/remixicon.dart'; import 'package:webview_flutter/webview_flutter.dart'; class BoardDialog extends StatefulWidget { final WebViewController controller; const BoardDialog({super.key, required this.controller}); @override State createState() => _BoardDialogState(); } class _BoardDialogState extends State { bool _loading = false; @override void initState() { super.initState(); // 绑定加载事件 widget.controller.setNavigationDelegate( NavigationDelegate( onPageStarted: (_) { setState(() => _loading = true); }, onPageFinished: (_) { setState(() => _loading = false); }, ), ); } @override Widget build(BuildContext context) { return Container( color: Colors.white, padding: const EdgeInsets.all(16), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('白板', style: Theme.of(context).textTheme.titleSmall), IconButton( onPressed: () => context.pop(), icon: const Icon(RemixIcons.close_circle_fill), ), ], ), Expanded( child: Stack( children: [ WebViewWidget( controller: widget.controller, ), if (_loading) Container( color: Colors.white, child: const Center( child: CircularProgressIndicator(), ), ), ], ), ), ], ), ); } }