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',
},
);
Related
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
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.
The searchBoxPage is on one screen, the Search result is on SearchResultPage.
Search box page on submit it will route by Get.toNamed('/search-result?qry=$value');.
First going to the SearchResult page, SearchResultController onReady is working properly.
Second time when going back searchBoxPage and on submit SearchResultController onReady is NOT working properly.
So I'm looking to dispose SearchResultPage before route to the page.
I have a home page that displays results based on some user information. From results page user can navigate to profile page and edit information. After edit information, they navigate back to home page. The problem is, the home page not refreshed with new results. It still shows old results. How can i reload this page with the new data.
home.page.ts:
openProfilePage() {
this.router.navigate(['/profile']);
}
profile.page.ts
onSubmit() {
this.router.navigate(['/home'], {replaceUrl: true});
}
You can trigger a call you need to make to update the info on:
ionViewDidEnter() {
console.log('ionViewDidEnter ');
// call update function
}
ionViewWillEnter(){
//here you check data is changed or not and call your function according to that this method call every time when navigate to home page
}
The main interface for my app is dynamically built based upon whether or not the app has been activated. I created a previous route service that uses Angular’s Activated Route to detect if the main interface needs to be updated without doing a complete refresh.
I have an app with multiple pages where some pages are skip depending on the user selection...
for example, I have the following page
details.dart
contact.dart
address.dart
code.dart
summary.dart
I would like to go to another page from any of the above pages...However, I want first check to see if they are in the stack and then pop to it. Otherwise push that page onto the stack
How do I do this in Flutter
I think you might want to use Navigator.of(context).pushNamedAndRemoveUntil or Navigator.popUntil.
They are very similar however like the name suggests pushNamedAndRemoveUntil pushes a new route when the predicate matches, while popUntil re-uses an existing Route/Widget in the tree.
You can read more about them on this wonderful Medium post explaining all options in greater detail.
You can use routes inside materialApp, after home
return MaterialApp(
home:... ,
routes:{
"/routeName" : (context) => PageRoute()
}
and then call route name from any pages
Ex : app in Contact page need to move to PageRoute
//Contact Page
...
onTap:(){
Navigator.pushReplacementName(context,'/routeName');
}
just use multiple Navigator.pop