My main screen is Tabbarview. I have different error states, and need to implement different UI for each. What is the best approach to deal with this if I only want one instance of Tabbarview, but need to have errors shown like this:
- State1 Error: show specific error inside individual tab content
- State2 Error: show error pop-up on top of Tabbarview, but hide tab content
- State3 error: show generic error on all tabs
- State4 error: show error fullscreen
2
Answers
Are you using a state management library in your project, such as Bloc, Provider, or any other?
Here is how I will do it.
I will create an enum to group the definition of all error cases.
I will add the variable to track the error state in my StatefulWidget
And I will implement the display of errors in separate functions
This approach allows you to keep a single instance of TabBarView and manage the display according to different possible error states.