Skip to content

Commit

Permalink
v1.1.1 (#16)
Browse files Browse the repository at this point in the history
* Fix #14 by introducing an artificial delay when delivering the result from the plugin to the consumer.

* Update changelog and pubspec.
  • Loading branch information
roughike committed Apr 4, 2018
1 parent 4f88932 commit 001d639
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.1.1

* Fix occasional hangs/freezes by introducing a slight artifical delay after getting the result from Facebook login.

## 1.1.0

* Dart 2 support! There should not be any breaking changes. Please do file issues if you have problems.
Expand Down
19 changes: 17 additions & 2 deletions lib/flutter_facebook_login.dart
Expand Up @@ -103,7 +103,8 @@ class FacebookLogin {
'permissions': permissions,
});

return new FacebookLoginResult._(result.cast<String, dynamic>());
return _deliverResult(
new FacebookLoginResult._(result.cast<String, dynamic>()));
}

/// Logs the user in with the requested publish permissions.
Expand All @@ -129,7 +130,8 @@ class FacebookLogin {
'permissions': permissions,
});

return new FacebookLoginResult._(result.cast<String, dynamic>());
return _deliverResult(
new FacebookLoginResult._(result.cast<String, dynamic>()));
}

/// Logs the currently logged in user out.
Expand Down Expand Up @@ -165,6 +167,19 @@ class FacebookLogin {

throw new StateError('Invalid login behavior.');
}

/// There's a weird bug where calling Navigator.push (or any similar method)
/// straight after getting a result from the method channel causes the app
/// to hang.
///
/// As a hack/workaround, we add a new task to the task queue with a slight
/// delay, using the [Future.delayed] constructor.
///
/// For more context, see this issue:
/// https://github.com/roughike/flutter_facebook_login/issues/14
Future<T> _deliverResult<T>(T result) {
return new Future.delayed(const Duration(milliseconds: 500), () => result);
}
}

/// Different behaviors for controlling how the Facebook Login dialog should
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_facebook_login
description: A Flutter plugin for allowing users to authenticate with native Android &amp; iOS Facebook login SDKs.
version: 1.1.0
version: 1.1.1
author: Iiro Krankka <iiro.krankka@gmail.com>
homepage: https://github.com/roughike/flutter_facebook_login

Expand Down

0 comments on commit 001d639

Please sign in to comment.