I have a method that returns one of two stateful widgets, based on the value of an enum. However, even though I can see via the debugger that the "correct" widget is being returned, the UI only ever shows the first one that is rendered. It seems the state object is somehow being shared across different instances of the widget, or I'm missing something.
Widget _buildInfoCard(LoginStatus status) {
switch(status) {
case LoginStatus.LOGIN_FAILED:
return InfoCard("Login failed, please check your username and password.");
default:
return InfoCard("Please login with your username and password");
}
}
I expect that the displayed infocard will have the text that corresponds to the text of the returned info card, but the default case always presents. I've stepped through the code, the correct widget is returned, and the default widget is not returned after that, so it should be displayed, but does not.
EDIT: The _buildInfoCard method gets called inside of a streambuilder.