popup that will appear once with flutter - flutter

According to the information from the system, I want the user to see a popup when he first logs into the application.I want.Any ideas on how to do it?
For example, a person who completes a hospital appointment evaluates the service he received with a pop-up that will appear the next time he logs into the application.I want this popup to appear only once. The person went to the hospital, completed his appointment, this information came from the system, and the next time he entered, a popup appeared directly in front of him. This is the scenario

You can use: https://pub.dev/packages/shared_preferences
When app is start then dialog is open you to save one boolean like isFirstTime == false
await prefs.setBool('newUser', isFirstTime);
When your is came again into the app, have to check in pref boolean is available or not
final bool? isFirstTime = prefs.getBool('newUser');
if(isFirstTime){
openDialog();
}
if the value is false then will not show pop up

Related

How to hide update dialog box when app is running for the first time in flutter

I am using upgrader package for showing dialog box telling user to update the app. Now, I don't want it to pop up when user is opening the app for the first time. How should I achieve this? Is there a field where I can put some kind of condition which can be true/false and accordingly it will show me the box?
You can use shared preference to save the value. for example, you can set an integer value with the name isTheFirstTime and set it to 0 which you can consider as a false.
and when you run the app for the first time it will check this value which is false and put this condition before your widget:
if(theValueYouChecked){ yourWidget }
At the first time, theValueYouChecked will be false, set the value in your dialog function in the shared preference to true so that when you run the app any time except for the first time you will get true so your widget will appear.

How does one check the state of a menu item in an XCUI test

Here is my use case...
My application has a number of menu items that have their state toggled between on and off based on a boolean that is also tied to a user default. That is, when the user clicks the menu item it not only toggles the state, it also saves that in the user defaults.
This is all working well but I'm trying to add tests to my XCUIApplication tests to check that the state is indeed saved from one application run to another. However I am unable to determine how to actually test the state of the menu item.
I find the menu item and confirm that it exists, has the correct title, and is enabled, as seen here:
let item = app.menuItems["viewHighlightChanges"]
XCTAssertTrue(item.exists)
XCTAssertEqual(item.title, "Highlight Changes")
XCTAssertTrue(item.isEnabled)
I can then toggle the item by clicking it:
item.click()
And I can confirm visually that this is all working.
But what I cannot figure out is how to determine if the menu item is check (state is on) or not checked (state is off). I had thought that it may be encoded in item.value but that is returning nil both before and after the click. I also thought it may be in item.isSelected but selected is not the same as state and in this case is always false both before and after the click.
My goal is to record the state after clicking, then exit and restart the app, and test the state again to see that it properly retained itself. I know that it is working because I can verify the state visually as the test runs, but the whole purpose of an automated test is that the computer should tell me if it worked.
Any ideas?

Ionic content not updating after callback from external plugin

As part of the functionality of the app we are developing, when an android alarm is fired, a dialog box is to appear with an "Accept" or "Reject" button. Selecting reject does nothing, but selecting "Accept" triggers a callback from the plugin, which I have passed a function into. This function causes the ionic app to navigate to the root page of the app.
The issue I am having is, when I then navigate to another page after that where the user selects a value, and this value is displayed back to them and a button is enabled, the value display is not updating, and the button is not becoming enabled. Nothing seems to be updating.
What I have found is that pressing the back button on my android device will cause the page to update, which is not ideal.
This functionality works without the callback from the plugin.
What is happening here? And how do I fix it?
Passing the function into the plugin.
alarms_plugin.onAlarmRecieved = (alarmId) =>{
this.events.publish('alarmRecieved', alarmId);
}
Plugin-side functions
alarmRecieved: function(alarmId){
alarms_plugin.onAlarmRecieved(alarmId);
}
onAlarmRecieved: null
Navigating to root page on alarmRecieved
this.events.subscribe('alarmRecieved', (alarmId) =>{
if(alarmId != 'TIMEOUT')
this.nav.setRoot(HomePage);
});
Fix found by surrounding the this.nav.setRoot(HomePage) in this.zone.run(..).
Supposedly calling navigation within a subscription event causes issues like I was having.

How to make my flutter app return the user to the OS home screen?

I'm working on an app that will have a lock screen, but I'm having some issues getting it to behave correctly. Right now I'm using the didChangeAppLifecycleState to navigate to the lock screen when the user suspends/resumes the app. I'm also using the WillPopScope to intercept and deny the back button. The problem with this approach is that pressing the back button and having nothing happen doesn't feel super intuitive. Ideally, I'd like the back button to take the user out of the app and back to their OS home screen when they're on the lock screen. I also want to do this in a way that the user's route history is maintained for when they successfully unlock the app.
Is there any way to accomplish what I'm trying to do, or should I just accept that the back button won't do anything on the lock screen?
You can create an identifier in your LockScreen state and check for the identifier in onWillPop and if the user is pressing the back button from the lock screen, exit the app.
String identifier = "lockscreen";
bool onWillPop() {
if (identifier == "lockscreen") {
SystemNavigator.pop();
SystemChannels.platform.invokeMethod('SystemNavigator.pop'); //preferred.*
return true;
}
}
SystemNavigator.pop(): On iOS, calls to this method are ignored because Apple's human interface guidelines state that applications should not exit themselves.

Template10 - return user to the main page after resuming

Let's assume that my UWP app gets suspended and it is not used for a long time. When a user opens the app again (previous ApplicationExecutionState is Suspended or Terminated), I don't want the user to be navigated to the page he/she was viewing last (it became irrelevant since then), but instead do a fresh navigation to the main page. How can I do this using Template10?
It seems that when the user returns to the app, Template10 always returns the user to the page which was being viewed last. I tried overriding the OnResuming method in App.xaml.cs, however it had no effect.
I had this problem.
I solved saving a bool property like ItWasSuspended in the LocalSettings of my app.
When the OnResumming is activated I set to True this property or when the launched event was raised I set this property false.
Finally in my pages in the OnNavigatedTo I get the value of this property if this property is true I navigate to the main page and I clear the back stack.
Here is how to use the local settings
https://msdn.microsoft.com/library/windows/apps/windows.storage.applicationdata.localsettings.aspx
you can clear the back stack doing something like this
this.Frame.BackStack.Clear();
please mark this answer if it's useful for you!
Best regards