-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor state management for other screens #335
Refactor state management for other screens #335
Conversation
|
||
class LoginScreenContent extends StatelessWidget { | ||
const LoginScreenContent({super.key, required this.onLoginPressed}); | ||
final LoginScreenViewModel viewModel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The descendent widgets should not know about the view model. We should pass the value listenable from the viewmodel through the root widget.
|
||
final AuthService _authService; | ||
|
||
final _loginState = StatefulValueNotifier<bool>.idle(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's simplify this by removing the state
concept. We can simply name this as isLoggedIn
.
_viewModel.onLoginPressed(email, password); | ||
}, | ||
); | ||
return LoginScreenContent(viewModel: _viewModel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The descendents should never have dependency to the ViewModel
@@ -0,0 +1,52 @@ | |||
import 'package:coffee_maker_navigator_2/features/add_water/domain/entities/water_source.dart'; | |||
|
|||
class AddWaterState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new approach aims to avoid creating separate State classes. We should avoid combining multiple fields in one class. For example, the footer widget only depends on errorMessage
and isReadyToAddWater
and it should not be re-built when waterSource for example changes.
af87ce3
into
woltapp:state-management-experiments-in-demo-app
Description
Applied new state management approach to other screens and view models