Complete BLoC with Clean Architecture (group chat) Discount !! E-commerce App With Backend Source Code Video and Voice Chatting App Firebase Chatting App Source Code Complete Gym App BLoC State Management Source Code Complete Study App Buy Ticket Booking App Source Code Buy Travel App With Backend Source Code Complete Chat App Udemy Course Special Offer Discount !! Online Learning Course App (BLoC) Online Learning Course App (Riverpod) Online Learning Course App (Getx) Discount !! Shopping App (Provider) Cool Flutter Game Flutter Nodejs Chat App Flutter Nodejs Api And Firebase Chat App Riverpod Task Management App
Inside TabView you can put as many views as you want. TabView put item horizontally. In general you will see the first one. That’s the default set up.
But you can change it. To change it you may declare a State variable at the top and then assign tag() function for each view inside the TabView.
What’s tag() function?
It’s a function that produces value(hashable) which could be used to keep track of your view specially with TabView. There are other cases where you can use tag().
After that if your State variable matches with tag() function value, then that certain TabView would be the first one. In that case it would ignore the default view order to show.
But if your State variable value and tag() value don’t match then, it would go back to the default order meaning that, you will see the first view on the screen that you put in the TabView().
So to control which view to show on the screen, you may declare a State variable and that variable value should match tag() function value.
So now we can take it one step further, TabView could work with Button view and bind them together as you tap using tag() function and State variable value.
State variable value could be changed as you tap on the Button and that changed value could match the value of tag() inside TabView. This is how you may also create a custom TabBar in SwiftUI.