@@ -122,33 +122,38 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
122
122
///
123
123
/// It forces refresh regardless of token expiration if [forceRefresh]
124
124
/// parameter is `true` .
125
- Future <String > getIdToken ([bool forceRefresh = false ]) =>
126
- jsObject.getIdToken (forceRefresh.toJS).toDart as Future <String >;
125
+ Future <String > getIdToken ([bool forceRefresh = false ]) => jsObject
126
+ .getIdToken (forceRefresh.toJS)
127
+ .toDart
128
+ .then ((value) => value! as String );
127
129
128
130
/// Links the user account with the given credentials, and returns any
129
131
/// available additional user information, such as user name.
130
132
Future <UserCredential > linkWithCredential (
131
133
auth_interop.OAuthCredential ? credential) =>
132
- ( auth_interop.linkWithCredential (jsObject, credential).toDart
133
- as Future <auth_interop. UserCredentialJsImpl >)
134
- . then ( UserCredential .fromJsObject );
134
+ auth_interop.linkWithCredential (jsObject, credential).toDart. then (
135
+ (value) => UserCredential . fromJsObject (
136
+ value ! as auth_interop. UserCredentialJsImpl ) );
135
137
136
138
/// Links the user account with the given [phoneNumber] in E.164 format
137
139
/// (e.g. +16505550101) and [applicationVerifier] .
138
140
Future <ConfirmationResult > linkWithPhoneNumber (
139
141
String phoneNumber, ApplicationVerifier applicationVerifier) =>
140
- (auth_interop
141
- .linkWithPhoneNumber (
142
- jsObject, phoneNumber.toJS, applicationVerifier.jsObject)
143
- .toDart as Future <auth_interop.ConfirmationResultJsImpl >)
144
- .then (ConfirmationResult .fromJsObject);
142
+ auth_interop
143
+ .linkWithPhoneNumber (
144
+ jsObject, phoneNumber.toJS, applicationVerifier.jsObject)
145
+ .toDart
146
+ .then ((value) => ConfirmationResult .fromJsObject (
147
+ value! as auth_interop.ConfirmationResultJsImpl ));
145
148
146
149
/// Links the authenticated [provider] to the user account using
147
150
/// a pop-up based OAuth flow.
148
151
/// It returns the [UserCredential] information if linking is successful.
149
- Future <UserCredential > linkWithPopup (AuthProvider provider) =>
150
- auth_interop.linkWithPopup (jsObject, provider.jsObject).toDart
151
- as Future <UserCredential >;
152
+ Future <UserCredential > linkWithPopup (AuthProvider provider) => auth_interop
153
+ .linkWithPopup (jsObject, provider.jsObject)
154
+ .toDart
155
+ .then ((value) => UserCredential .fromJsObject (
156
+ value! as auth_interop.UserCredentialJsImpl ));
152
157
153
158
/// Links the authenticated [provider] to the user account using
154
159
/// a full-page redirect flow.
@@ -159,8 +164,11 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
159
164
/// available additional user information, such as user name.
160
165
Future <UserCredential > reauthenticateWithCredential (
161
166
auth_interop.OAuthCredential credential) =>
162
- auth_interop.reauthenticateWithCredential (jsObject, credential).toDart
163
- as Future <UserCredential >;
167
+ auth_interop
168
+ .reauthenticateWithCredential (jsObject, credential)
169
+ .toDart
170
+ .then ((value) => UserCredential .fromJsObject (
171
+ value! as auth_interop.UserCredentialJsImpl ));
164
172
165
173
/// Re-authenticates a user using a fresh credential.
166
174
/// Use before operations such as [updatePassword] that require tokens
@@ -172,14 +180,19 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
172
180
auth_interop
173
181
.reauthenticateWithPhoneNumber (
174
182
jsObject, phoneNumber.toJS, applicationVerifier.jsObject)
175
- .toDart as Future <ConfirmationResult >;
183
+ .toDart
184
+ .then ((value) => ConfirmationResult .fromJsObject (
185
+ value! as auth_interop.ConfirmationResultJsImpl ));
176
186
177
187
/// Reauthenticates a user with the specified provider using
178
188
/// a pop-up based OAuth flow.
179
189
/// It returns the [UserCredential] information if reauthentication is successful.
180
190
Future <UserCredential > reauthenticateWithPopup (AuthProvider provider) =>
181
- auth_interop.reauthenticateWithPopup (jsObject, provider.jsObject).toDart
182
- as Future <UserCredential >;
191
+ auth_interop
192
+ .reauthenticateWithPopup (jsObject, provider.jsObject)
193
+ .toDart
194
+ .then ((value) => UserCredential .fromJsObject (
195
+ value! as auth_interop.UserCredentialJsImpl ));
183
196
184
197
/// Reauthenticates a user with the specified OAuth [provider] using
185
198
/// a full-page redirect flow.
@@ -251,8 +264,8 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
251
264
? jsObject.getIdTokenResult ()
252
265
: jsObject.getIdTokenResult (forceRefresh.toJS);
253
266
254
- return ( promise.toDart as Future <auth_interop. IdTokenResultImpl >)
255
- . then ( IdTokenResult ._fromJsObject);
267
+ return promise.toDart. then ((value) =>
268
+ IdTokenResult ._fromJsObject (value ! as auth_interop. IdTokenResultImpl ) );
256
269
}
257
270
258
271
/// Returns a JSON-serializable representation of this object.
@@ -295,7 +308,7 @@ class IdTokenResult extends JsObjectWrapper<auth_interop.IdTokenResultImpl> {
295
308
/// custom, phone, password, etc).
296
309
///
297
310
/// Note, this does not map to provider IDs.
298
- String get signInProvider => jsObject.signInProvider.toDart;
311
+ String ? get signInProvider => jsObject.signInProvider? .toDart;
299
312
300
313
/// The Firebase Auth ID token JWT string.
301
314
String get token => jsObject.token.toDart;
@@ -330,7 +343,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
330
343
/// SMS templates for phone authentication, reCAPTCHA verifier and OAuth
331
344
/// popup/redirect operations provided the specified providers support
332
345
/// localization with the language code specified.
333
- String get languageCode => jsObject.languageCode.toDart;
346
+ String ? get languageCode => jsObject.languageCode? .toDart;
334
347
335
348
set languageCode (String ? s) {
336
349
jsObject.languageCode = s? .toJS;
@@ -462,8 +475,10 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
462
475
/// out-of-band mechanism.
463
476
/// It returns [ActionCodeInfo] , metadata about the code.
464
477
Future <auth_interop.ActionCodeInfo > checkActionCode (String code) =>
465
- (auth_interop.checkActionCode (jsObject, code.toJS).toDart)
466
- as Future <auth_interop.ActionCodeInfo >;
478
+ auth_interop
479
+ .checkActionCode (jsObject, code.toJS)
480
+ .toDart
481
+ .then ((value) => value! as auth_interop.ActionCodeInfo );
467
482
468
483
/// Completes password reset process with a [code] and a [newPassword] .
469
484
Future confirmPasswordReset (String code, String newPassword) => auth_interop
@@ -717,9 +732,10 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
717
732
/// Verifies a password reset [code] sent to the user by email
718
733
/// or other out-of-band mechanism.
719
734
/// Returns the user's e-mail address if valid.
720
- Future <String > verifyPasswordResetCode (String code) =>
721
- auth_interop.verifyPasswordResetCode (jsObject, code.toJS).toDart
722
- as Future <String >;
735
+ Future <String > verifyPasswordResetCode (String code) => auth_interop
736
+ .verifyPasswordResetCode (jsObject, code.toJS)
737
+ .toDart
738
+ .then ((value) => value! as String );
723
739
}
724
740
725
741
/// Represents an auth provider.
@@ -1019,7 +1035,8 @@ class PhoneAuthProvider
1019
1035
dynamic phoneOptions, ApplicationVerifier applicationVerifier) =>
1020
1036
jsObject
1021
1037
.verifyPhoneNumber (phoneOptions, applicationVerifier.jsObject)
1022
- .toDart as Future <String >;
1038
+ .toDart
1039
+ .then ((value) => value! as String );
1023
1040
1024
1041
/// Creates a phone auth credential given the verification ID
1025
1042
/// from [verifyPhoneNumber] and the [verificationCode] that was sent to the
@@ -1045,7 +1062,8 @@ abstract class ApplicationVerifier<
1045
1062
/// Executes the verification process.
1046
1063
/// Returns a Future containing string for a token that can be used to
1047
1064
/// assert the validity of a request.
1048
- Future <String > verify () => jsObject.verify ().toDart as Future <String >;
1065
+ Future <String > verify () =>
1066
+ jsObject.verify ().toDart.then ((value) => value! as String );
1049
1067
}
1050
1068
1051
1069
/// reCAPTCHA verifier.
@@ -1101,7 +1119,8 @@ class RecaptchaVerifier
1101
1119
1102
1120
/// Renders the reCAPTCHA widget on the page.
1103
1121
/// Returns a Future that resolves with the reCAPTCHA widget ID.
1104
- Future <num > render () => jsObject.render ().toDart as Future <num >;
1122
+ Future <num > render () =>
1123
+ jsObject.render ().toDart.then ((value) => value! as num );
1105
1124
}
1106
1125
1107
1126
/// A result from a phone number sign-in, link, or reauthenticate call.
@@ -1157,13 +1176,14 @@ class UserCredential
1157
1176
class AdditionalUserInfo
1158
1177
extends JsObjectWrapper <auth_interop.AdditionalUserInfoJsImpl > {
1159
1178
/// Returns the provider id.
1160
- String get providerId => jsObject.providerId.toDart;
1179
+ String ? get providerId => jsObject.providerId? .toDart;
1161
1180
1162
1181
/// Returns the profile.
1163
- Map <String , dynamic >? get profile => dartify (jsObject.profile);
1182
+ Map <String , dynamic >? get profile =>
1183
+ jsObject.profile != null ? dartify (jsObject.profile! ) : null ;
1164
1184
1165
1185
/// Returns the user name.
1166
- String get username => jsObject.username.toDart;
1186
+ String ? get username => jsObject.username? .toDart;
1167
1187
1168
1188
/// Returns whether a user is a new or returning user.
1169
1189
bool get isNewUser => jsObject.isNewUser.toDart;
0 commit comments