|
| 1 | +import 'package:firebase_auth/firebase_auth.dart'; |
1 | 2 | import 'package:firebase_messaging/firebase_messaging.dart'; |
2 | 3 | import 'package:flutter/cupertino.dart'; |
| 4 | +import 'package:flutter_riverpod/flutter_riverpod.dart'; |
3 | 5 |
|
| 6 | +import '../../api/user/user_models.dart'; |
4 | 7 | import '../../errors/app_error.dart'; |
5 | 8 | import '../../extensions/string_extensions.dart'; |
6 | 9 | import '../../storage/app_preferences.dart'; |
7 | 10 | import '../../storage/provider/preferences_provider.dart'; |
8 | 11 | import '../user/user_service.dart'; |
9 | | -import 'package:firebase_auth/firebase_auth.dart'; |
10 | | -import 'package:flutter_riverpod/flutter_riverpod.dart'; |
11 | | - |
12 | | -import '../../api/user/user_models.dart'; |
13 | 12 |
|
14 | 13 | final firebaseAuthProvider = Provider((ref) => FirebaseAuth.instance); |
15 | 14 |
|
@@ -61,21 +60,19 @@ class AuthService { |
61 | 60 | verificationCompleted: (phoneAuthCredential) async { |
62 | 61 | final userCredential = |
63 | 62 | await _auth.signInWithCredential(phoneAuthCredential); |
64 | | - _onVerificationSuccess(countryCode, phoneNumber, userCredential); |
65 | | - onVerificationCompleted != null |
66 | | - ? onVerificationCompleted(phoneAuthCredential, userCredential) |
67 | | - : null; |
| 63 | + await _onVerificationSuccess( |
| 64 | + countryCode, |
| 65 | + phoneNumber, |
| 66 | + userCredential, |
| 67 | + ); |
| 68 | + onVerificationCompleted?.call(phoneAuthCredential, userCredential); |
68 | 69 | }, |
69 | 70 | verificationFailed: (FirebaseAuthException e) => |
70 | | - onVerificationFailed != null |
71 | | - ? onVerificationFailed(AppError.fromError(e, e.stackTrace)) |
72 | | - : null, |
| 71 | + onVerificationFailed?.call(AppError.fromError(e, e.stackTrace)), |
73 | 72 | codeSent: (String verificationId, int? resendToken) => |
74 | | - onCodeSent != null ? onCodeSent(verificationId, resendToken) : null, |
| 73 | + onCodeSent?.call(verificationId, resendToken), |
75 | 74 | codeAutoRetrievalTimeout: (verificationId) => |
76 | | - onCodeAutoRetrievalTimeout != null |
77 | | - ? onCodeAutoRetrievalTimeout(verificationId) |
78 | | - : null, |
| 75 | + onCodeAutoRetrievalTimeout?.call(verificationId), |
79 | 76 | ); |
80 | 77 | } catch (error, stack) { |
81 | 78 | throw AppError.fromError(error, stack); |
|
0 commit comments