@@ -23,9 +23,9 @@ Auth getAuthInstance(App app) {
2323 // Default persistence can be seen here
2424 // https://github.com/firebase/firebase-js-sdk/blob/main/packages/auth/src/platform_browser/index.ts#L47
2525 final List <JSAny ?> persistences = [
26- auth_interop.indexedDBLocalPersistence as JSAny ,
27- auth_interop.browserLocalPersistence as JSAny ,
28- auth_interop.browserSessionPersistence as JSAny ,
26+ auth_interop.indexedDBLocalPersistence,
27+ auth_interop.browserLocalPersistence,
28+ auth_interop.browserSessionPersistence,
2929 ];
3030 return Auth .getInstance (
3131 auth_interop.initializeAuth (
@@ -128,15 +128,16 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
128128 Future <String > getIdToken ([bool forceRefresh = false ]) => jsObject
129129 .getIdToken (forceRefresh.toJS)
130130 .toDart
131- .then ((value) => ( value! as JSString ) .toDart);
131+ .then ((value) => value.toDart);
132132
133133 /// Links the user account with the given credentials, and returns any
134134 /// available additional user information, such as user name.
135135 Future <UserCredential > linkWithCredential (
136136 auth_interop.OAuthCredential ? credential) =>
137- auth_interop.linkWithCredential (jsObject, credential).toDart.then (
138- (value) => UserCredential .fromJsObject (
139- value! as auth_interop.UserCredentialJsImpl ));
137+ auth_interop
138+ .linkWithCredential (jsObject, credential)
139+ .toDart
140+ .then (UserCredential .fromJsObject);
140141
141142 /// Links the user account with the given [phoneNumber] in E.164 format
142143 /// (e.g. +16505550101) and [applicationVerifier] .
@@ -146,17 +147,15 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
146147 .linkWithPhoneNumber (
147148 jsObject, phoneNumber.toJS, applicationVerifier.jsObject)
148149 .toDart
149- .then ((value) => ConfirmationResult .fromJsObject (
150- value! as auth_interop.ConfirmationResultJsImpl ));
150+ .then (ConfirmationResult .fromJsObject);
151151
152152 /// Links the authenticated [provider] to the user account using
153153 /// a pop-up based OAuth flow.
154154 /// It returns the [UserCredential] information if linking is successful.
155155 Future <UserCredential > linkWithPopup (AuthProvider provider) => auth_interop
156156 .linkWithPopup (jsObject, provider.jsObject)
157157 .toDart
158- .then ((value) => UserCredential .fromJsObject (
159- value! as auth_interop.UserCredentialJsImpl ));
158+ .then (UserCredential .fromJsObject);
160159
161160 /// Links the authenticated [provider] to the user account using
162161 /// a full-page redirect flow.
@@ -170,8 +169,7 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
170169 auth_interop
171170 .reauthenticateWithCredential (jsObject, credential)
172171 .toDart
173- .then ((value) => UserCredential .fromJsObject (
174- value! as auth_interop.UserCredentialJsImpl ));
172+ .then (UserCredential .fromJsObject);
175173
176174 /// Re-authenticates a user using a fresh credential.
177175 /// Use before operations such as [updatePassword] that require tokens
@@ -184,8 +182,7 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
184182 .reauthenticateWithPhoneNumber (
185183 jsObject, phoneNumber.toJS, applicationVerifier.jsObject)
186184 .toDart
187- .then ((value) => ConfirmationResult .fromJsObject (
188- value! as auth_interop.ConfirmationResultJsImpl ));
185+ .then (ConfirmationResult .fromJsObject);
189186
190187 /// Reauthenticates a user with the specified provider using
191188 /// a pop-up based OAuth flow.
@@ -194,8 +191,7 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
194191 auth_interop
195192 .reauthenticateWithPopup (jsObject, provider.jsObject)
196193 .toDart
197- .then ((value) => UserCredential .fromJsObject (
198- value! as auth_interop.UserCredentialJsImpl ));
194+ .then (UserCredential .fromJsObject);
199195
200196 /// Reauthenticates a user with the specified OAuth [provider] using
201197 /// a full-page redirect flow.
@@ -240,7 +236,7 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
240236 Future <User > unlink (String providerId) => auth_interop
241237 .unlink (jsObject, providerId.toJS)
242238 .toDart
243- .then ((user) => User .getInstance (user! as auth_interop. UserJsImpl )! );
239+ .then ((user) => User .getInstance (user)! );
244240
245241 /// Updates the user's e-mail address to [newEmail] .
246242 Future <void > updateEmail (String newEmail) =>
@@ -267,8 +263,7 @@ class User extends UserInfo<auth_interop.UserJsImpl> {
267263 ? jsObject.getIdTokenResult ()
268264 : jsObject.getIdTokenResult (forceRefresh.toJS);
269265
270- return promise.toDart.then ((value) =>
271- IdTokenResult ._fromJsObject (value! as auth_interop.IdTokenResultImpl ));
266+ return promise.toDart.then (IdTokenResult ._fromJsObject);
272267 }
273268
274269 /// Returns a JSON-serializable representation of this object.
@@ -535,10 +530,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
535530 /// out-of-band mechanism.
536531 /// It returns [ActionCodeInfo] , metadata about the code.
537532 Future <auth_interop.ActionCodeInfo > checkActionCode (String code) =>
538- auth_interop
539- .checkActionCode (jsObject, code.toJS)
540- .toDart
541- .then ((value) => value! as auth_interop.ActionCodeInfo );
533+ auth_interop.checkActionCode (jsObject, code.toJS).toDart;
542534
543535 /// Completes password reset process with a [code] and a [newPassword] .
544536 Future confirmPasswordReset (String code, String newPassword) => auth_interop
@@ -565,7 +557,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
565557 .createUserWithEmailAndPassword (jsObject, email.toJS, password.toJS)
566558 .toDart;
567559
568- return UserCredential .fromJsObject (u! as auth_interop. UserCredentialJsImpl );
560+ return UserCredential .fromJsObject (u);
569561 }
570562
571563 /// Gets the list of possible sign in methods for the given email address.
@@ -587,13 +579,9 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
587579 /// if sign is unsuccessful.
588580 /// The [UserCredential] with a null [User] is returned if no redirect
589581 /// operation was called.
590- Future <UserCredential ?> getRedirectResult () => auth_interop
591- .getRedirectResult (jsObject)
592- .toDart
593- .then ((value) => value == null
594- ? null
595- : UserCredential .fromJsObject (
596- value as auth_interop.UserCredentialJsImpl ));
582+ Future <UserCredential ?> getRedirectResult () =>
583+ auth_interop.getRedirectResult (jsObject).toDart.then (
584+ (value) => value == null ? null : UserCredential .fromJsObject (value));
597585
598586 /// Sends a sign-in email link to the user with the specified email.
599587 ///
@@ -676,9 +664,10 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
676664 /// available additional user information, such as user name.
677665 Future <UserCredential > signInWithCredential (
678666 auth_interop.OAuthCredential credential) =>
679- auth_interop.signInWithCredential (jsObject, credential).toDart.then (
680- (value) => UserCredential .fromJsObject (
681- value! as auth_interop.UserCredentialJsImpl ));
667+ auth_interop
668+ .signInWithCredential (jsObject, credential)
669+ .toDart
670+ .then (UserCredential .fromJsObject);
682671
683672 /// Asynchronously signs in as an anonymous user.
684673 //
@@ -688,8 +677,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
688677 Future <UserCredential > signInAnonymously () => auth_interop
689678 .signInAnonymously (jsObject)
690679 .toDart
691- .then ((value) => UserCredential .fromJsObject (
692- value! as auth_interop.UserCredentialJsImpl ));
680+ .then (UserCredential .fromJsObject);
693681
694682 /// Asynchronously signs in using a custom token.
695683 ///
@@ -701,8 +689,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
701689 Future <UserCredential > signInWithCustomToken (String token) => auth_interop
702690 .signInWithCustomToken (jsObject, token.toJS)
703691 .toDart
704- .then ((value) => UserCredential .fromJsObject (
705- value! as auth_interop.UserCredentialJsImpl ));
692+ .then (UserCredential .fromJsObject);
706693
707694 /// Signs in a user asynchronously using a custom [token] and returns any
708695 /// additional user info data or credentials.
@@ -731,16 +718,14 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
731718 auth_interop
732719 .signInWithEmailAndPassword (jsObject, email.toJS, password.toJS)
733720 .toDart
734- .then ((value) => UserCredential .fromJsObject (
735- value! as auth_interop.UserCredentialJsImpl ));
721+ .then (UserCredential .fromJsObject);
736722
737723 /// Signs in using [email] and [emailLink] link.
738724 Future <UserCredential > signInWithEmailLink (String email, String emailLink) =>
739725 auth_interop
740726 .signInWithEmailLink (jsObject, email.toJS, emailLink.toJS)
741727 .toDart
742- .then ((value) => UserCredential .fromJsObject (
743- value! as auth_interop.UserCredentialJsImpl ));
728+ .then (UserCredential .fromJsObject);
744729
745730 /// Asynchronously signs in using a phone number in E.164 format
746731 /// (e.g. +16505550101).
@@ -765,7 +750,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
765750 .toDart;
766751
767752 return ConfirmationResult .fromJsObject (
768- result! as auth_interop. ConfirmationResultJsImpl ,
753+ result,
769754 );
770755 }
771756
@@ -775,8 +760,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
775760 Future <UserCredential > signInWithPopup (AuthProvider provider) => auth_interop
776761 .signInWithPopup (jsObject, provider.jsObject)
777762 .toDart
778- .then ((value) => UserCredential .fromJsObject (
779- value! as auth_interop.UserCredentialJsImpl ));
763+ .then (UserCredential .fromJsObject);
780764
781765 /// Signs in using a full-page redirect flow with the given [provider] .
782766 Future signInWithRedirect (AuthProvider provider) =>
@@ -803,7 +787,7 @@ class Auth extends JsObjectWrapper<auth_interop.AuthJsImpl> {
803787 Future <String > verifyPasswordResetCode (String code) => auth_interop
804788 .verifyPasswordResetCode (jsObject, code.toJS)
805789 .toDart
806- .then ((value) => ( value! as JSString ) .toDart);
790+ .then ((value) => value.toDart);
807791
808792 /// Initializes the reCAPTCHA Enterprise client proactively to enhance reCAPTCHA signal collection and
809793 /// to complete reCAPTCHA-protected flows in a single attempt.
@@ -1216,8 +1200,7 @@ class ConfirmationResult
12161200 Future <UserCredential > confirm (String verificationCode) => jsObject
12171201 .confirm (verificationCode.toJS)
12181202 .toDart
1219- .then ((value) => UserCredential .fromJsObject (
1220- value! as auth_interop.UserCredentialJsImpl ));
1203+ .then (UserCredential .fromJsObject);
12211204}
12221205
12231206/// A structure containing a [User] , an [OAuthCredential] and [operationType] .
0 commit comments