Please check the following code below.
void initState() {
ref.listenManual(
timerControllerProvider,
(previous, next) {
if (next.remainingSeconds == 300) {
showAlertDialogButton_1(context, "5 Minutes remaining");
} else if (next.remainingSeconds == 0) {
context.goNamed(NameConstants.timeFinishPage,
);
}
},
);
}
My question is.. Can i use navigation from initState
?
2
Answers
You’ll want to use
fireImmediately: true
if you want to possibly show the modal immediately:Adding to this, you’re not naturally allowed to show modals directly inside
initState
. You’ll have to delay theshowModal
:Also works for navigation: