OAuthLaunch: Ignore Platform exceptions

The OAuthFlow doesn't work properly in ios, for now lets just ignore
these exceptions as short of forking the url_launcher, I see no other
way of fixing this.

If the Flutter team can release a fix in a week or so, then I'll just
wait, otherwise I'll probably just fork the url_launcher and close the
FSafariViewController on receiving an error. It wouldn't be a proper
fix, but it will work around the issue.

https://github.com/flutter/flutter/issues/30642
This commit is contained in:
Vishesh Handa
2019-10-11 16:42:23 +02:00
parent 57b37399ef
commit 0ad3a9e2e6

View File

@ -1,6 +1,8 @@
import 'package:fimber/fimber.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:function_types/function_types.dart';
import 'package:gitjournal/analytics.dart';
import 'package:gitjournal/apis/git.dart';
import 'package:gitjournal/apis/githost_factory.dart';
@ -37,7 +39,7 @@ class GitHostSetupAutoConfigureState extends State<GitHostSetupAutoConfigure> {
super.initState();
}
void _startAutoConfigure() {
void _startAutoConfigure() async {
Fimber.d("Starting autoconfigure");
setState(() {
_configuringStarted = true;
@ -94,7 +96,14 @@ class GitHostSetupAutoConfigureState extends State<GitHostSetupAutoConfigure> {
}
widget.onDone(repo.cloneUrl);
});
gitHost.launchOAuthScreen();
try {
await gitHost.launchOAuthScreen();
} on PlatformException catch (e, stack) {
print("LaunchOAuthScreen: Caught platform exception: " + e.toString());
print(stack);
print("Ignoring it, since I don't know what else to do");
}
} on GitHostException catch (e) {
_handleGitHostException(e);
}