我有一个非st小部件,在这里我打开一个where视图来执行oAuth。我希望能够跟踪用户何时到达某个页面并关闭when视图。
目前,甚至打印语句也没有被执行!此外,我注意到在StreamSubsctiption部分中,它说“字段'_onWebviewStateChange‘的值没有被使用”。
我做错什么了?
我的守则:
class RedditAuth extends StatefulWidget {
static const String id = 'redditAuth';
@override
_RedditAuthState createState() => _RedditAuthState();
}
class _RedditAuthState extends State<RedditAuth> {
// Initialise the RedditAuthClass and the FlutterWebviewPlugin
RedditAuthClass authorizeReddit = RedditAuthClass();
FlutterWebviewPlugin flutterWebviewPlugin = FlutterWebviewPlugin();
// Subscribe to the WebViewStateChanged
StreamSubscription<WebViewStateChanged> _onWebviewStateChange;
//
@override
void intiState() {
super.initState();
_onWebviewStateChange = flutterWebviewPlugin.onStateChanged.listen(
(WebViewStateChanged state) {
print('State has changed: ${state.url}');
if (state.url == 'https://www.google.com') {
flutterWebviewPlugin.hide();
}
},
);
}
// @override
//Dispose any stream subs
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('data'),
),
body: SafeArea(
child: WebviewScaffold(
url: authorizeReddit.auth(),
hidden: true,
),
),
);
}
}
发布于 2020-06-25 20:46:58
当我更改这部分代码时,它就开始工作了。现在我需要弄清楚为什么:
flutterWebviewPlugin =新的FlutterWebviewPlugin();
https://stackoverflow.com/questions/62583614
复制相似问题