Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit d6d4d7b

Browse files
committed
Move updateProfile from FirebaseAuth to FirebaseUser. Minor cleanup in Java.
1 parent 880415b commit d6d4d7b

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

packages/firebase_auth/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public void onMethodCall(MethodCall call, Result result) {
136136
}
137137

138138
private void handleSignInWithPhoneNumber(MethodCall call, Result result) {
139+
@SuppressWarnings("unchecked")
139140
Map<String, String> arguments = (Map<String, String>) call.arguments;
140141
String verificationId = arguments.get("verificationId");
141142
String smsCode = arguments.get("smsCode");
@@ -447,18 +448,7 @@ private void handleUpdateProfile(MethodCall call, final Result result) {
447448
firebaseAuth
448449
.getCurrentUser()
449450
.updateProfile(builder.build())
450-
.addOnCompleteListener(
451-
new OnCompleteListener<Void>() {
452-
@Override
453-
public void onComplete(@NonNull Task<Void> task) {
454-
if (!task.isSuccessful()) {
455-
Exception e = task.getException();
456-
result.error(ERROR_REASON_EXCEPTION, e.getMessage(), null);
457-
} else {
458-
result.success(null);
459-
}
460-
}
461-
});
451+
.addOnCompleteListener(new TaskVoidCompleteListener(result));
462452
}
463453

464454
private void handleStartListeningAuthState(MethodCall call, final Result result) {

packages/firebase_auth/lib/firebase_auth.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ class FirebaseUser extends UserInfo {
108108
);
109109
}
110110

111+
/// Updates the user profile information.
112+
Future<void> updateProfile(UserUpdateInfo userUpdateInfo) async {
113+
assert(userUpdateInfo != null);
114+
return await FirebaseAuth.channel.invokeMethod(
115+
'updateProfile',
116+
userUpdateInfo._updateData,
117+
);
118+
}
119+
111120
@override
112121
String toString() {
113122
return '$runtimeType($_data)';
@@ -382,14 +391,6 @@ class FirebaseAuth {
382391
return currentUser;
383392
}
384393

385-
Future<void> updateProfile(UserUpdateInfo userUpdateInfo) async {
386-
assert(userUpdateInfo != null);
387-
return await channel.invokeMethod(
388-
'updateProfile',
389-
userUpdateInfo._updateData,
390-
);
391-
}
392-
393394
/// Links google account with current user and returns [Future<FirebaseUser>]
394395
///
395396
/// throws [PlatformException] when

0 commit comments

Comments
 (0)