requestCode method
Implementation
Future<String?> requestCode() async {
_code = null;
final urlParams = _constructUrlParams();
final launchUri = Uri.parse('${_authorizationRequest.url}?$urlParams');
final controller = WebViewController();
await controller.setNavigationDelegate(_navigationDelegate);
await controller.setJavaScriptMode(JavaScriptMode.unrestricted);
await controller.setBackgroundColor(Colors.transparent);
await controller.setUserAgent(_config.userAgent);
await controller.loadRequest(launchUri);
final webView = WebViewWidget(controller: controller);
if (_config.navigatorKey.currentState == null) {
throw Exception(
'Could not push new route using provided navigatorKey, Because '
'NavigatorState returned from provided navigatorKey is null. Please Make sure '
'provided navigatorKey is passed to WidgetApp. This can also happen if at the time of this method call '
'WidgetApp is not part of the flutter widget tree',
);
}
await _config.navigatorKey.currentState!.push(
MaterialPageRoute(
builder: (context) => Scaffold(
body: SafeArea(
child: Stack(
children: [_config.loader, webView],
),
)),
),
);
return _code;
}