Skip to content

Commit 8b0b849

Browse files
committed
* added stack trace to onLoginFailed and onError callbacks
1 parent 2db2d50 commit 8b0b849

4 files changed

Lines changed: 31 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## [1.0.6] - 16/07/2022
22

3+
* **BREAKING:** Added stack trace to onLoginFailed and onError callbacks
34
* Added a boolean linkWithExistingUser to link the new credentials with an existing signed-in user, instead of creating a new one.
45
* Added onError callback for general purpose errors by the library
56

@@ -10,9 +11,9 @@
1011

1112
## [1.0.5] - 10/07/2022
1213

13-
* BREAKING: Renamed flag timeOutDuration to autoRetrievalTimeOutDuration
14-
* BREAKING: Renamed verifyOTP to verifyOtp
15-
* BREAKING: Updated verifyOtp function signature to not take a named argument, and accept otp as a positional argument
14+
* **BREAKING:** Renamed flag timeOutDuration to autoRetrievalTimeOutDuration
15+
* **BREAKING:** Renamed verifyOTP to verifyOtp
16+
* **BREAKING:** Updated verifyOtp function signature to not take a named argument, and accept otp as a positional argument
1617
* Added a new otpExpirationDuration flag, as autoRetrievalTimeOutDuration is a completely different parameter.
1718
* Added callback onCodeSent and flag signOutOnSuccessfulVerification
1819
* Added isSendingCode flag to controller

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ FirebasePhoneAuthHandler(
121121
debugPrint("autoVerified: $autoVerified");
122122
debugPrint("Login success UID: ${userCredential.user?.uid}");
123123
},
124-
onLoginFailed: (authException) {
124+
onLoginFailed: (authException, stackTrace) {
125125
debugPrint("An error occurred: ${authException.message}");
126126
},
127-
onError: (error) {},
127+
onError: (error, stackTrace) {},
128128
),
129129
```
130130

@@ -320,12 +320,12 @@ class _VerifyPhoneNumberScreenState extends State<VerifyPhoneNumberScreen>
320320
(route) => false,
321321
);
322322
},
323-
onLoginFailed: (authException) {
323+
onLoginFailed: (authException, stackTrace) {
324324
showSnackBar('Something went wrong!');
325325
log(VerifyPhoneNumberScreen.id, error: authException.message);
326326
// handle error further if needed
327327
},
328-
onError: (error) {
328+
onError: (error, stackTrace) {
329329
showSnackBar('An error occurred!');
330330
},
331331
builder: (context, controller) {

lib/src/auth_controller.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ class FirebasePhoneAuthController extends ChangeNotifier {
155155
autoVerified: false,
156156
);
157157
}
158-
} on FirebaseAuthException catch (e) {
159-
_onLoginFailed?.call(e);
158+
} on FirebaseAuthException catch (e, s) {
159+
_onLoginFailed?.call(e, s);
160160
return false;
161-
} catch (e) {
162-
_onError?.call(e);
161+
} catch (e, s) {
162+
_onError?.call(e, s);
163163
return false;
164164
}
165165
}
@@ -180,7 +180,7 @@ class FirebasePhoneAuthController extends ChangeNotifier {
180180
}
181181

182182
verificationFailedCallback(FirebaseAuthException authException) {
183-
_onLoginFailed?.call(authException);
183+
_onLoginFailed?.call(authException, null);
184184
}
185185

186186
codeSentCallback(
@@ -220,11 +220,11 @@ class FirebasePhoneAuthController extends ChangeNotifier {
220220
}
221221

222222
return true;
223-
} on FirebaseAuthException catch (e) {
224-
_onLoginFailed?.call(e);
223+
} on FirebaseAuthException catch (e, s) {
224+
_onLoginFailed?.call(e, s);
225225
return false;
226-
} catch (e) {
227-
_onError?.call(e);
226+
} catch (e, s) {
227+
_onError?.call(e, s);
228228
return false;
229229
}
230230
}
@@ -267,11 +267,11 @@ class FirebasePhoneAuthController extends ChangeNotifier {
267267
if (_signOutOnSuccessfulVerification) await signOut();
268268
_onLoginSuccess?.call(authResult, autoVerified);
269269
return true;
270-
} on FirebaseAuthException catch (e) {
271-
_onLoginFailed?.call(e);
270+
} on FirebaseAuthException catch (e, s) {
271+
_onLoginFailed?.call(e, s);
272272
return false;
273-
} catch (e) {
274-
_onError?.call(e);
273+
} catch (e, s) {
274+
_onError?.call(e, s);
275275
return false;
276276
}
277277
}

lib/src/type_definitions.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@ import 'dart:async';
33
import 'package:firebase_auth/firebase_auth.dart';
44

55
typedef OnLoginSuccess = FutureOr<void> Function(UserCredential, bool);
6-
typedef OnLoginFailed = FutureOr<void> Function(FirebaseAuthException);
7-
typedef OnError = FutureOr<void> Function(Object);
6+
7+
typedef OnLoginFailed = FutureOr<void> Function(
8+
FirebaseAuthException,
9+
StackTrace?,
10+
);
11+
12+
typedef OnError = FutureOr<void> Function(
13+
Object,
14+
StackTrace,
15+
);

0 commit comments

Comments
 (0)