Open
Conversation
- For the first time user, the user will be asked to sign up - For the exiting users after their email is authenticated, they will be able to login anytime
- Favorited items will be specific for each user - A log out button is added
Nei1eveN
suggested changes
May 24, 2021
| String? _userId; | ||
| Timer? _authTimer; | ||
|
|
||
| bool get isAuth { |
Contributor
There was a problem hiding this comment.
please put short description
| return token != null; | ||
| } | ||
|
|
||
| String? get token { |
| return null; | ||
| } | ||
|
|
||
| String? get userId { |
| return _userId; | ||
| } | ||
|
|
||
| Future<void> _authenticate(String? email, String? password, String urlSegment) async { |
Comment on lines
+64
to
+81
| Future<void> signUp(String? email, String? password) async { | ||
| return _authenticate(email, password, 'signUp'); | ||
| } | ||
|
|
||
| Future<void> login(String? email, String? password) async { | ||
| return _authenticate(email, password, 'signInWithPassword'); | ||
| } | ||
|
|
||
| void logout() { | ||
| _token = null; | ||
| _userId = null; | ||
| _expiryDate = null; | ||
| if (_authTimer != null) { | ||
| _authTimer?.cancel(); | ||
| _authTimer = null; | ||
| } | ||
| notifyListeners(); | ||
| } |
Contributor
There was a problem hiding this comment.
please document all methods
| ///Class for arguments that the navigator needs | ||
| class EditProductArguments { | ||
| final String productId; | ||
| final String? productId; |
Contributor
There was a problem hiding this comment.
may I ask why this productId is nullable?
| static const routeName = '/edit-product'; | ||
|
|
||
| final EditProductArguments editProductarguments; | ||
| final EditProductArguments? editProductarguments; |
Contributor
There was a problem hiding this comment.
Document methods and constructors
| String validatorTitle(String value) { | ||
| return value.isEmpty ? 'Error description example' : null; | ||
| String? validatorTitle(String? value) { | ||
| return value!.isEmpty ? 'Error description example' : null; |
Contributor
There was a problem hiding this comment.
replace this with nullable approach:
value?.isEmpty == true
| class ProductDetailScreen extends StatelessWidget { | ||
| static const routeName = '/product-detail'; | ||
| final String productDetailArgs; | ||
| final String? productDetailArgs; |
Contributor
There was a problem hiding this comment.
may I know why this is nullable? Is there a chance that this can be optional?
| Widget build(BuildContext context) { | ||
| final productsData = Provider.of<ProductsProvider>(context); | ||
| final products = showFavs ? productsData.favoriteItems : productsData.items; | ||
| final products = showFavs! ? productsData.favoriteItems : productsData.items; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
able to login anytime
Problem:
Even if the user is already authenticated,
ProductOverviewScreenstill does not show after clicking the login button.