我当前正在使用flutter_webview_plugin,并试图在用户单击网站内的链接时添加加载指示器。我知道在最初加载网站时这是可能的,但是一旦用户进入网站并在webview中导航,就不知道如何实现。我当前的代码如下:
class _MyHomePageState extends State<MyHomePage> {
final flutterWebviewPlugin = new FlutterWebviewPlugin();
@override
Widget build(BuildContext context) {
return WebviewScaffold(
url: "samplewebsite.com",
withJavascript: true,
withZoom: false,
clearCookies: true,
//clearCache: true,
hidden: true,
//withLocalStorage: false,
appBar: AppBar(
titleSpacing: 0.0,
//title: Text("Sample Website"),
backgroundColor: Color(0xFF021818),
actions: <Widget>[
InkWell(
child: Icon(Icons.refresh),
onTap: (){
flutterWebviewPlugin.reload();
},
),
FlatButton(
textColor: Colors.white,
onPressed: () {
flutterWebviewPlugin.reloadUrl("samplewebsite.com/page1");},
child: Text("PAGE1"),
shape: CircleBorder(side: BorderSide(color: Colors.transparent)),
),
FlatButton(
textColor: Colors.white,
onPressed: () {
flutterWebviewPlugin.reloadUrl("samplewebsite.com/page2");},
child: Text("PAGE2"),
shape: CircleBorder(side: BorderSide(color: Colors.transparent)),
),
FlatButton(
textColor: Colors.white,
onPressed: () {
flutterWebviewPlugin.reloadUrl("samplewebsite.com/login");},
child: Text("LOGIN"),
shape: CircleBorder(side: BorderSide(color: Colors.transparent)),
),
]),
);
}
任何对此的澄清将不胜感激。