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.
Related
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
I have a basic layout for a webapp I'm trying to build with flutter. Basically there is a navbar on the left side of the screen and the content should fill the rest of the page.
Whenever a user clicks a link in the navbar, the content should update accordingly. I have an understanding on how this would work with the "old" Navigator and named routes. However, users need to be able to access certain content directly by url and the url may contain parameters, so do I have to use a Router?
From my (limited) understanding, I have to use MaterialApp.router to use a Router, but this will always redraw the WHOLE page, including the navbar.
Is there an option to update only the content part, without updating the surrounding layout?
Thanks in advance!
Go check out navigationRail in flutter, if that helps.
I am learning integration_test for my dynamic app.
The home screen may contain any number (normally 9-13) of Widgets (including 4/6 bottom Nav items) of different types depending on the location and server configurations of that user. So, Home Screen is building dynamically and varies from user to user.
I am trying to find a way to get the list of Widgets on the home screen and Tap them serially in the integration test. Is there any way to perform this task?
Any idea will be highly appreciated.
Thanks
You should know which widgets will be there based on the user you use for each test. Therefore you should interact with them accordingly
in my flutter application, I have 4 types of items to display. Each item has its own View/Pages. Based on which type of item the user clicks, the app needs to load the corresponding page. I am using getx pattern in the app. The routes are defined in app_pages.dart. I have a module for each of the 4 different type pages.
The simplest way I know is to put a condition check on the item's onPressed. But I need to get a proper way of implementing this. Another method I have tried is by adding the condition in the app_pages.dart based on the Ger.arguments. But there the problem is the whole widgets in the stack get rebuild on screen resizing due to the keyboard showing up and all. So at that time, the condition fails because the Get.argument is null.
Here is my question, I have a simple grid list, where each tile contains a text and a favorite icon.
That grid is linked to a provider (which contains all the data), and each tile is linked to a nested provider which points to an individual element of the list provided above.
Now when I click on a tile I navigate to a details page, which just shows the name of the object, a favorite icon (outlined or not if the object is favorite or not) and a button "mark as favorite".
(I do that via Navigator with an argument representing my object, that I retrieve after from the grid provider)
Now when I click on the button I want to mark that object as a favorite, which is working fine (in the grid it shows the good status thanks to the provider), BUT how do I update my details page right away ?
Should I always use a stateful widget in that case ? or is there another way to "listen" to my item provider ?
I suppose that somehow I should be able to mark my details page as a listener of my provider, but I don't know how cause the details page is not in the same hierarchy as my grid tile...
Thanks for any feedback on this !