requestCode method
Implementation
Future<String> requestCode() async {
var code;
final String urlParams = _constructUrlParams();
// workaround for webview overlapping statusbar
// if we have a screen size use it to adjust the webview
await _webView.launch(
"${_authorizationRequest.url}?$urlParams",
clearCookies: _authorizationRequest.clearCookies,
hidden: true,
rect: (_config.screenSize.height > 0 && _config.screenSize.width > 0) ? Rect.fromLTWH(
0.0,
25.0,
_config.screenSize.width,
_config.screenSize.height-25) : null
);
_webView.onStateChanged.listen((WebViewStateChanged change) {
if ( change.type.index == 2)
_webView.show();
});
_webView.onUrlChanged.listen((String url) {
Uri uri = Uri.parse(url);
Uri configUri = Uri.parse(_authorizationRequest.redirectUrl);
if ( uri.host == configUri.host )
_onCodeListener.add(uri.queryParameters["code"]);
});
code = await _onCode.first;
await _webView.close();
return code;
}