I am trying out async_redux for Flutter and like the idea with nested states.
I have a AppState like this:
class AppState {
final LoginState loginState;
AppState({this.loginState});
AppState copy({LoginState loginState}) {
return AppState(
loginState: loginState ?? this.loginState,
);
}
...
And my LoginState:
class LoginState {
final bool isLoggedIn;
LoginState({this.isLoggedIn});
LoginState copy({bool isLoggedIn}) {
return LoginState(isLoggedIn: isLoggedIn ?? this.isLoggedIn);
}
...
But how do I make my reducer update the isLoggedIn in my LoginState? I have tried a few things, but not getting anywhere. This obvious isnt working, but just to give a starting point:
class LoginAction extends ReduxAction {
final String username;
final String password;
LoginAction({this.username, this.password}) : assert(username != null && password != null);
@override
AppState reduce() {
return state.copy(loginState: state.loginState.isLoggedIn = true);
}
}
Any ideas?
Thank you
Søren