customize bottom navigation in flutter - flutter

I'm working on a flutter project and I want to add a bottom navigation bar but I want to add a variable that show how many BottomNavigationBarItem it will be in this bottom navigation bar, for example if I set a value to 5 I Will have 5 BottomNavigationBarItem in my bottom navigation, if I change it to 3 I will have just 3. Is there a way to do it. Any help is highly appreciated.

Just declare a variable to store the count of the items in the BottomNavigationBar and use it to generate the items.
If the variable is changing dynamically and you want to reflect that change to the BottomNavigationBar then set the widget containing the BottomNavigationBar as a StatefulWidget and follow the same concept in this answer to complete the rest of the task.

Related

Is there any way I can implement pull down appbar in flutter?

Can anyone suggest to me how can I build a pull-down appbar. I searched the whole net but can't find any idea regarding this. It would be great if anyone could guide or suggest to me to build the appbar.
Edit:-
Many developers are saying to use SliverAppBar. SliverAppBar basically collapses the app bar when we scroll up the listview or any other widget, whereas I want an app bar that pulls down i.e when we tap the app bar and scroll it down only the app bar grows on top of the body. So basically when we navigate to the home screen the app bar should look like the second referred image i.e it must be closed. But we can pull down that appbar to view the hidden contents of the appbar. I am attaching an image for reference.
I Think what you mean what pull down App is an Appbar that expands try.
the silver Appbar
https://youtu.be/mSc7qFzxHDw

How do you create a side navigation drawer that persists across pages?

I've looked through many tutorials for the side nav drawer. I can create one that works fine to lead to different pages. However, when I travel to a page that's different from home, it only gives me the arrow icon to go back to home at the top left instead of keeping the button to bring me back to the side navbar. How can I prevent this?
I can't use the home page to navigate everywhere because it's just supposed to be a blank splash screen.
You can define your drawer in a separate widget file, that you can import everywhere you have a scafold.
I created a package for it because I was missing similar functionality. If you want a Flutter approach for this navigation check out: https://api.flutter.dev/flutter/material/NavigationRail-class.html
Or if you want to have a look at my package: https://pub.dev/packages/side_navigation
It's because you're moving to a new page/Scaffold (probably using Navigator.push()). So, the default button in the AppBar will be the back button.
You can either have the same Drawer in every Scaffold you navigate to, which is not recommended since you'll just keep pushing routes to the navigation stack.
Or, you can change pages within the Scaffold. Check the interactive examples in BottomNavigationBar and NavigationRail to get an idea of how to do it. Basically instead of calling Navigator.push() when a tile in Drawer is tapped, just update the selected index and call setState().

Dart/Flutter: change content of container on tab in ListView

I am currently trying to create something like a TabBar. I created a horizontal ListView which should work as the TabBar and I my goal is, that one row fills itself with a list that contains the cards for the Tab I clicked on and refreshes when I click on another one. Is there a way to do that? It should look like this:
Reference Picture
Did you look at Work with tabs, an introduction to TabBar, TabBarView and DefaultTabController?
You could also create it from scratch using a ListView with a Card wrapped in a GestureDetector or a ListTile, and detect taps on onTap, which would set the selected data and update state using setState.

Flutter Not able to achieve PageView like Swipeable Tabs inside Parent ListView

This is a Flutter Specific Query.
I Want to achieve the Layout Referenced in the Image above. Two Tabs
Below a Container.
The Tabs can be switched using Swipe Animation like that in a
Page View.
The Tabs Contain Dynamically Generated Widgets from Provider.
The Entire Page along with the Fixed Container must be
Scroll-able.
When Switching between the Tabs the fixed container should stay
in place and only tab Content(Column of Widgets) should swipe
left and right.
What I've Tried :
Using a Parent List View and Nesting the Fixed Container Child
and Using Tab Bar to switch the Widget using Animated Switcher and
Slide Animation. Here the Problem is i cannot swipe left and right
and create the Page View like Effect. I also tried Nesting Page-View
inside List-View but since the Page-View does not have a fixed height
( because the tab contents are dynamically generated ).
A few many more concepts i tried to tackle but the issue every time was
that the tab contents are not having a fixed height.
I really want to achieve this Layout and i want to know if there's any way.

How do I create Vertical tabBar in Flutter?

How do I create Vertical tabBar in Flutter? Unlike TabBar where tabs are displayed in a horizontal row, I want to place them vertically in a Column. see this example
For your use case, it would be easier to use NavigationRail instead of trying to rotate everything.
The solution was simple. Here what I did. I wrapped the TabBar in a RotatedBox after decorating & styling it. And finally, wrapped everything inside PreferredSize and done.
Update on 30 Oct 2021: Use navigation Rail instead or something else from pub.dev.
Check out Drawer example in flutter gallery, they have the use case defined, and it provides many samples