Flutter : Cloud Firestore upload progress indicator - flutter

I have a list of items in a catalog page with an add button. When I click the add button, it takes me to a form where I can upload an image and description. When I hit save, the data gets saved asynchronously to firebase. While the data is being saved, a progress bar is displayed on the screen and page is popped when done and takes me back to the catalog page.
What I would like to do is pop the form page right away on save and show save progress as in the catalog page. How do I go about doing that?

You'll have to create bloc or a cubit of some kind that will carry out the upload mechanism. Once you hit save, you'll have a bloc event that will start the upload and emit state according to the upload progress.
Since the upload is taken care of by the bloc you can pop the form page right after clicking save and have a bloc builder of some kind that will show the progress on the catalog page.
This bloc will be shared by both the pages, so you'll have to use dependency injection in my opinion.

Related

How to clear routing without moving to another page Flutter Getx

I can go to my page PgMain by a lot of way (end of action, logout, button go to menu, button back, system back button, etc.). I want clear my routing every time, where I open PgMain page. How to do it inside PgMain class, for example inside build method? As I said previously, I have a lot of ways to go to PgMain, and not at every case I can use Get.offAll() method
Use
Get.offAll(PgMain()); Get.off(PgMain());
whenever you navigate to PgMain page.

Device back button has different result rather than getx toNamed

I have two screen, first is for load list off all shop data and second is the detail screen of the shop. When I'm in second page and go back with arrow icon with Get.toNamed the first screen will load all list again but when I in the second page and I go back with my device back button in the first page it just showing loader icon and the list not loading. Can someone help me why it can be happen ?
Use Get.off() or follow this article.

Is there a way to save state in Flutter so the App starts off from where we left off?

I want data to be persistence. I want the state to be same from where I left off before closing the app. Is there a way to achieve this in flutter?
I dont know this is the right solution for this, but maybe you can save the last pages path to sharedpreferences every time user navigates to a page, then when your app is opening, read the last page from shared preferences and navigate to that page.

Flutter Show a page every time the user opens the app, until they click a button, then it should show a different page when they open the app

The problem I’m asking is how to have a kind of page (call it SetupPage) that is only shown until the user presses a button on the screen. Then when the screen should show the next page(call it HomePage) and every time the app is opened after the button press, the normal page will be HomePage.
I’ve seen this general idea in many apps (sign-in and home page, enter phone number or school and main page, etc) and I would like to have it in my app! I’m thinking of using Navigator routes and having the stack be this at first:
(HomePage, SetupPage)
and then once the button is pressed I can pop SetupPage. But I’m not sure how to implement this.
I already have the SetupPage and HomePage classes made. I’m not doing a sign-in the SetupPage or anything like that. I’m not using FireBase in this app either.
You can use the Flutter package shared_preferences to save a Boolean that tell you at the start of the program is the button pressed or not.

Flutter form without save button? (Auto save as user types)

Is it possible to build forms in Flutter that autosave forms without a Save button? What would be the mechanism? Checking for a timeout since last keystroke? Or save when the user navigates away from the screen?