Refreshing a view after context.pop() with go_router and bloc - flutter

I have 2 different views with two different blocs.
One page displays data that is edited on the second page.
When I upload values from my bloc on the second page and execute a context.pop to return to the first page, the first page doesn’t reaload and since they’re separate bloc, it’s not noticing any change
I am using go_router (i can’t use navigator for navigation)
I tried to make an async call to execute after it comes back but i couldn’t

I was able to solve this issue by adding unique keys to my pages in go router!
see more here: https://github.com/flutter/flutter/issues/100969#issuecomment-1289944809

Related

Flutter navigator.push, set it to only push once, disallow user to press multiple times to push multiple pages

My app receives in-app notifications from Firebase. When the notification is pressed, it will prompt the user to the page.
My issue is if the notification is pressed multiple times, it will push the same page multiple times, causing to have lots of the pages in the stack. Is it possible to configure and limit Navigator.push to push only once?
I have tried using pushReplacemement but I'm still facing the same issue.
PushReplacement will not work since it always create new instances of widget every time.
I can see 2 ways to fix it:
Manage while pushing: You can try to store a variable (or as persistent data) that stores if the page has been pushed or not and only push if it is the first time.
Manage while poping: If the number of pages doesn't matter and all you care about is going back to the main screen on pressing back, use the popUntil method to pop until to return to the desired page.
Although I do not know the context of your application, getting same notification multiple time is probably not a good idea. You should probably change the functionality there instead. (Just a suggestion and do your own research).

The route.first page (MyHomePage) is updating even without a callback, function or notification listener

I can't really share code for this as it's for my entire ~large~ application, but is it normal for a flutter application's lower navigation stack to be updated when the current page is?
For example, in this page I have a standard form with a few TextFormFields:
Whenever I click on one to start typing the page sets state as expected, but by adding print("Update"); inside the build function of the bottom page of the navigation stack, I can see that page is being updated too. It happens on all pages I put on top of the first route page. I've also been experiencing that the home page gets slower as the app has been open for longer, could this be a cause for that problem too?

Updating URL from TabBar selection

I'm currently working on updating a Flutter Web app to support sharing pages via URLs. I currently have a screen that uses a TabBar, and shows different views based on the selected tab. I want to be able to do two things:
Update the URL when a tab is selected (e.g. append &section=tabName to the URL)
Paste the URL into a new browser tab and have the application open on the tab specified by the URL
The second part of this was simple enough, just take the &section=... argument and use that to set the initialIndex of the tab controller. Updating the URL however seems quite difficult.
I've tried using RouteInformationParser to generate a new route from a list of arguments, but that triggers the onGenerateRoute callback and just seems to re-navigate to the page with the initialIndex updated from the new URL. I can get around this by replacing the TabBarView with a nested Navigator that navigates to the selected tab's content, but it seems like this could quickly become quite clunky if you wanted to navigate deeper than just a selected tab.
A simpler option I've seen mentioned is window.history.replaceState, which seems a lot simpler but feels like a bit of a kludge. Are there any ways of doing this that I've missed?
Thanks!
It's a little hacky, but I was able to force a URL change on tabbed navigation by using the TabBar.onTap, which provides the tab index, and having navigation happen through that. It ruined the nice slide action, but I got the custom URL in the address bar, which was more important for my use.

update and pass data to next tab on navigation rail in flutter

I am using navigation rail and I am trying to pass data from one tab to next from the body but I am unable to do so and I haven't find any resource on it. Kindly guide me ,if there is any other widget that can perform the task I am trying to achieve
For Passing Data Between Widgets, you need to pass it from a common parent. in your case, your first page should save its data in the MainPage(The Page holding the NavigationRail) and then the second Page gets its data from MainPage.
This type of problem is more commonly solved by using a state management solution. The Flutter site has a list of them here.
Provider is an easy to use package that can provide an object throughout your widget tree. this way you can get a shared object between the two pages and use it to exchange data.

How to manage state in flutter?

I have a page from which I navigate to another page and do something there , when I press back button, the current page simply pop and previous page keep as it is. I have to refresh it to make changes.
I want, when I make change to second page, first page should automatically get updated according to it.
You should read a little about managing state in flutter.
There are few very good ideas on how to approach this problem.
You can try with fairly simple Scoped Model.
or little bit more confusing Inherited widgets. If you ever used Theme.of(context) or Navigator.of(context) that is basically inherited widget. Just a little more harder to set up properly.
Check this amazing presentation on managing it from google io 2018
https://youtu.be/RS36gBEp8OI