1

I am Uploading data through API in the backed but during the upload time i want that screen should freeze and person can't click on the same button until the previous data is stored. Is it possible in Flutter

  • 1
    You can use this https://pub.dev/documentation/progress_dialog/latest/ with `isDismissible: false` show the progress untill the process complete and you need to handle backbutton with WillPopScope untill process complete because it if you press back button while showing progress bar it goback to previous screen but the progressbar will be present so you need to handle backbutton until the process complete like initialize a bool variable set to false and when the the process complete set bool to true and check if it true then goback to previous screen – Abhijith Aug 17 '21 at 05:45
  • 1
    refer my answer [here](https://stackoverflow.com/a/68767696/13997210) for submit data to API hope its helpful to you – Ravindra S. Patil Aug 17 '21 at 07:12

1 Answers1

0

Flutter is declarative, in that: UI = F(state). UI is a function of state.

If you want to lock something in the UI, set a state variable to indicate this and have the UI respond to this.

More specifically, for instance set a isLoading style state variable (be it through a stateful widgets setState or a state management approach, e.g. Provider) when your API call starts and then set it back to false once the API call ends. In your UI then have the UI block either the whole page, or the button in question, if that state variable isLoading == true

Paul Popiel
  • 930
  • 11
  • 21