I am using GetX to develop an App. I have several pages that should show the same text value(Every page has its own text widget, and these text widgets should show the same value). When I click a button in Setting Page. These pages should change the text value at the same time?
How to accomplish global notification in GetX.
You should declare the value you want to show across your app to be observable so the controller can keep track of it
String sameValue = "same value".obs;
and the way you want show it on the UI is like
Obx(() => Text("${your_controller.sameValue}"))
Related
So lets say I have 3 Pages : [StartingPage, NamePage, AdressPage] inside a PageView.
Each of those children has a TextFormField inside it.
When I am at StartingPage I want to call .validate() on the keys of the TextFormFields on NamePage and AdressPage and I want the errorLabels to show, when the user navigates to the other pages. The problem is that currently, the validation only works for the TextFormFields that are on screen.
So basically there are two questions:
Is it possible to pre-build pages of a pageview? Otherwise when I call formFieldKey.currentState the state is null if I haven't navigated to the respective page.
Is there another way to validate offscreen TextFormField content and show the errorlabel, when they come into view?
Unfortunately Flutter Dosen't Support Multi-Page Forms So You Need To Implement Advanced State Management To Make This Happen.
I Used Riverpod To Create a 4 Page Form By Creating A Form Key For Every Page And Saving The State of the Forms, This Way Every Form Will keep Its State Until You Dispose Of it, Hope This Helped.
I have a problem with my Here Maps Navigation. I can start the navigation on my flutter app but every time I open another page on the app and come back to the navigation page, it restarts the navigation. It tries to get the current location again, takes a lot of time to do that, and shows the default "invalid" map page. I want the navigation to save it's current state even if I change the view to another page on my app and come back to navigating. Is there a way to do this? Am I missing something here?
I finally found a way to solve it by saving the state of my Flutter pages. I used the PageView widget for the main.dart's scaffold body and AutomaticKeepAliveClientMixin on the pages I wanted to save the states of. You can check this YouTube video for how to implement this: https://www.youtube.com/watch?v=fGe45NikVqE
I'm building multiple form pages in one class, I create 4 widgets each widgets is represent a page with text fields or cards or radio buttons.
and I create a method to switch between pages when. I press next.
This works as expected ^^
My issue UI inside first page is not refreshed unless I press ctrl + S,,
inside the first page of the form, I have created custom radio buttons they're simply cards.
and when tap on any card, there's set state method, to highlight the selected card by changing its style..
This works perfectly! at the beginning when I call the first page 1 directly as a child inside the scaffold..
However, after I created the method to switch between pages.. The UI in page 1 does not refresh..
I will put a picture..
Picture of the method to switch pages
Picture of pages widgets
picture of scaffold and how I call the widget pages
this is a picture of custom radio button which has cards, the card color change if it's selected
I tried many ways! but it didn't work..
Is what I'm trying to do correct? I'm a beginner in flutter
& I have a project to submit :(
I couldn't find a solution in google,,
Try making the widgets StatefulWidget and call setState((){}) inside the widget when you tap on the cards.
So here's what I did ^^
because the issue was just in page 1, so I in the scaffold I added page 1 as it's child directly without Switch page method..
Then inside page1, a button that will navigate to another class,
the second class has exactly the same scaffold and app bar as previous page.. But, in it's child I added calledWidget which switch between pages from 2 to 4 in my case ^^
So short words, I put page 1 in a separate page and the rest of the pages in a switch method in separate class
it works, but I hope I don't find any difficulties When saving values & integrating API to post the values
what you think?
I am been trying to implement this time picker UI. I used SingleChildScrollView() to implement the scrolling but I am not getting it how to retrieve the data which user selects.
I used NotificationListener() but it is only notifying me where user is starting and ending the scrolling.
I want to retrieve the value where user stops. How to do that ? Click link to view UI.
enter image description here
I think you should try ListWheelScrollView class which has more appropriate design for this case and provides a callback onSelectedItemChanged. So you can retrieve desired value from it.
This widget works like a ListView with focused sections and also have some nice features for customization.
I have an app with a bunch of text views inside a form. When the form scrolls, I lose the text entered in the above text fields. I would like to preserve those values. I tried adding a controller and assigning the value to a variable inside the state class but it does not work.
P.S not just widgets, but almost every type of input for example drop down buttons, radio buttons and what not.
I had a bunch of small forms inside a list view. Turns out, scrolling far enough, destroys the forms not visible to the user destroying their state. I need to lift their state up to the parent widget. For more information on how to do that, check how to keep the state of my widgets after scrolling?