consider
class AquariusProApp extends StatelessWidget {
final LocalStorage cLocalStorage;
final Database cDatabase;
const AquariusProApp(
{super.key, required this.cDatabase, required this.cLocalStorage});
@override
Widget build(BuildContext context) {
myDebugPrint("in AquariusProApp build");
return MultiProvider(
providers: [
ChangeNotifierProvider<Authenticator>(
create: (context) => Authenticator(
cDatabase: cDatabase, cLocalStorage: cLocalStorage)),
],
child: MaterialApp(
title: kProgramName,
theme: aquariumManagerTheme,
home: Consumer<Authenticator>(builder: (context, authenticator, child) {
myDebugPrint("in consumer");
if (authenticator.isLoading) {
return const Center(child: CircularProgressIndicator());
} else if (authenticator.hasToken) {
return HomeView(cAuthenticator: authenticator);
} else {
return AuthenticatorView(cAuthenticator: authenticator);
}
}),
),
);
}
}
I change variables in the ChangeNotifier Authenticator class and call notifylisteners:
void resetAuthentication() {
// we clear the saved token and reset the screen to the login page
cLocalStorage.deleteSecureStorage(kAuthenticationInfo);
_isPasswordBad = false;
_isLoading = false; // we are NOT loading; we are headed to the authenticator screen
_hasToken = false;
myDebugPrint("in resetAuthentication");
myDebugPrint("about to call notify 3");
notifyListeners();
}
However, the consumer build code is never called from this particular function. Why might this be?
There are numerous references to similar scenarios, but none solves my particular problem here.