I want to show my popup survey only once in the app lifecycle once the user completes the survey, meaning when the user restarts the app, the popup should not appear again. What happens now is if user restarts the app, the popup still shows again.
Help will be appreaciated
my code for popup
void showGenexPopup() {
WidgetsBinding.instance.addPostFrameCallback((_) {
final GenexViewModel genexViewModel =
Provider.of<GenexViewModel>(context, listen: false);
if (!genexViewModel.videoTrigger) {
genexViewModel.showSurvey(
context: context,
pageId: GenexPageId.SearchPage,
duration: const Duration(seconds: 5),
);
}
});
}
where I am calling it:
@override
void initState() {
super.initState();
showGenexPopup();
}
I am calling the popup in a webview, I do not know if it will have any effect on what I want to achieve.
Is it possible for me to achieve this?
3
Answers
Thanks guys for your responses. You really assisted me in getting to my answer using sharedPreference.
This is the approach that worked for me:
As @amir_a14 suggests u should use shared preferences where you save a key that indicate that the user took this survey once he complete it. Then before you call show survey check this key in the SharedPref and if this value is settled to the right value or exist at all
which will be in general like this:
Use SharedPrefrence library