Flutter: Phoenix rebirth then navigate to a specific page - flutter

I'm working on an app that contains more than one workspace to switch between them.
The user can receive notifications from the workspaces (all of them, even if he is not in this workspace)
When he clicks on the notification, it switches the workspaces (switch then reset the di and every thing then make the rebirth action using flutter_phoenix) then he should navigate to the specific page
The app works very well until finished the rebirth action, then didn't navigate to the specific page, just the home page after switching.
An example with this block of code:
Phoenix.rebirth(navigatorKey.currentContext!);
navigatorKey.currentState!.pushNamed(
taskDetailsRoute,
arguments: TaskDetailsPageArgs(
taskId: taskId,
),
);
That happens only after making this rebirth, It works very well if wanted to navigate if it's in the same workspace.

Related

Flutter mobile app, clicking an existing and valid physical back button is not working, even though the Cucumber step succeeds

I am using JDK 1.8_202, appium 2.0.0-beta.46, node v18.12.0
There is a programmer developed back button (<--) whose className as "android.widget.Button" whose className as "android.widget.Button", but when I try to verify it using search option, I am getting this pop up.
Programmatically nothing is happening, even though as a CucumberBDD step, it is showing as executed.
I am executing on locally connected physical device 'Samsung galaxy note 8'
Why back button tap/click action is not working even when it is executed??
I open my flutter mobile app. I am at landing page
Do some navigation forward. Comeback to a dashboard page
From dashboard page to get back to landing page, there is a back button like (<--), which I manual tap and can get back to landing page, with no problem.
Programmatically nothing is happening, even though as a CucumberBDD step, it is showing as executed.
From Appium Inspector I see it's className as "android.widget.Button", but when I try to verify it using search option, I am getting this pop up.
The same button with the same click() method is working fine in another scenario.
I am using JDK 1.8_202, appium 2.0.0-beta.46, node v18.12.0
Does the previous navigation affects the functioning of the button click() action ? It should not be logically.
Why back button tap/click action is not working even when it is executed??

Flutter Bloc: How to implement bloc to bloc communication

n project I have a Home page(with list of movie data) with HomeBloc. On clicking the a single movie cell I navigate to movie details page which has MovieDetailsBloc. Now in the details page I can edit name or make movie as favourite etc, this needs to be reflected in Home page.
To update the Home page after a change in Movie details page, I am sending HomeBloc to Movie details page like this
MovieDetailsPage(homeBloc: <instance of HomeBloc>)
and in the MovieDetailsBloc I am calling the event of HomeBloc to update the Home page like this
homeBlocInstance.add(<home event>)
This method is working.
My question is Is this good method like passing bloc to a page? There will be many places from where this Home page may need to be updated. For example
Make changes in settings -> Update home page
In this case should I pass the Home bloc to settings page? But what if the navigation is like this Home page -> Summary page -> settings page, should I keep passing the HomeBloc from Home page to Summary page and then settings page? This does not seem right.
Am i doing it right?
or is there any better solution?
If you're using GoRouter, When you're navigate back to home, you can just pass param to the router state, so when you are go to homepage you can do some process.
For example :
context.goNamed(
'home',
queryParams:{
'somestate': 'somevalue',
'somesetting': 'settingValue',
},
);

Flutter: push multiple pages on stack

I am using Getx for route management.
When coming from deepLink and the app is terminated, I want the app to launch (with splashscreen) and then go to a specific /match/:match_id route (I have the id in the deepLink).
This works well. The problem is that I want to push below this match page, the home page so that when the user goes back he can go there.
Within the initState of the LaunchScreen widget I am doing
Get.offNamed("/home"); // remove `LaunchScreen` and push `Home`
Get.offNamed("/match/:" + match_id); // push `Match`
This works. However there is some inconsistency with animations. I see for few seconds the Home page and then immediately the Match
I would like to jump directly to Match and the user not even seeing the Home one

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.

Prevent cached iPhone webapp from reloading (scrolling to top)

I have an iPhone webapp that uses a cache manifest to work offline. I add the webapp to my home screen, use it (say scroll to a certain location on a page), then go back to homescreen.
When I open the app again, for a brief moment I see where I used to be (at that scrolled location on that page), but then the app "reloads" and I get scrolled to the top of the mainpage. Is there a way to prevent this "reloading"? This happens even in airplane mode (ie everything is working off the cache).
You're just seeing the default startup image, which is just a screenshot of the last place you were at. It's not "reloading"; the app wasn't loaded to begin with.
Search for "apple-touch-startup-image" to set a real loading image.
What I'm struggling with here is that the app actually seems to stay "in memory" longer if I use regular Safari as opposed to running in "apple-mobile-web-app-capable" mode. In the later case something as simple as pressing the home button, then task-switching back to the app causes a reload. Doing the same thing just in Safari often does not reload. So I'm worse off by using "apple-mobile-web-app-capable".
I don't believe there is a real 'reload' event. onload and onunload are all we get.
the onload handler starts up as if it is your first time coming to the page.
the onunload handler is the key to clearing out old content.
I like to provide alternate content for people who are coming back to my web app.
window.onunload=function(){
document.getElementsByTagName('body')[0].className+=' unloading'
}
And let the CSS do the dirty work to hide most of the body and show alternate content.
(this answer does not rely on jQuery or other frameworks)
// on load
window.scroll(0,0);
To ensure no old content is displayed while launching I use this in my page:
window.addEventListener('unload', function() { $('body').hide(); } );
Thus the last state of the page is empty and is what is shown to the user when the page is opened again.