Skip to content

Commit

Permalink
Fixed userStateChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalramdan17 committed Jun 8, 2021
1 parent 24c5d16 commit e96509d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.1.7 - Updates (8 June 2021)

- Added `GetxFire.userChanges()` for `user current changes` stream.
- Added `GetxFire.userStateChanges(setState)` for `user current state changes` streaming automatically.
- Updated Readme File.

## 0.1.6 - Updates (7 June 2021)

- Updated Readme File for detail documentation.
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ dependencies:
getxfire: <latest-version>
```


### Import the library
```
import 'package:getxfire/getxfire.dart';
Expand Down Expand Up @@ -266,15 +265,21 @@ await GetxFire.signInWithGoogle(
```
GetxFire.currentUser
```
example :
```
User user = GetxFire.currentUser;
```

#### For Get Current User Changes
Add this inside `void initState()` function at statfullwidget :
```
GetxFire.userChanges().listen((event) => setState(() {}));
```

#### For Get Current User Changes State
#### For Get Current User State Changes
Add this inside `void initState()` function at statfullwidget :
```
GetxFire.userChanges().listen((event) => setState(() {}));
GetxFire.userStateChanges(setState);
```

# References
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/signin_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _SignInPageState extends State<SignInPage> {
@override
void initState() {
// GetxFire.userChanges().listen((event) => setState(() {}));
GetxFire.useStateChanges();
GetxFire.userStateChanges(setState);
super.initState();
}

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.6"
version: "0.1.7"
google_sign_in:
dependency: "direct main"
description:
Expand Down
8 changes: 3 additions & 5 deletions lib/getxfire.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ class GetxFire {
/// instead use [authStateChanges], [idTokenChanges] or [userChanges] to
/// subscribe to updates.
///
static StreamSubscription<User?> useStateChanges(
[Function(void)? setState]) =>
_auth
.userChanges()
.listen((event) => setState == null ? null : setState(() {}));
static StreamSubscription<User?> userStateChanges(
void Function(void Function()) setState) =>
_auth.userChanges().listen((event) => setState(() {}));

///
///Initializes a new [FirebaseApp] instance by [name] and [options] and returns the created app. This method should be called before any usage of FlutterFire plugins.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: getxfire
description: A Flutter Package that implemented firebase services with getx package.
version: 0.1.6
version: 0.1.7
homepage: https://github.com/faisalramdan17/getxfire/wiki
repository: https://github.com/faisalramdan17/getxfire

Expand Down

0 comments on commit e96509d

Please sign in to comment.