I'm currently working on a Flutter app in which I'd like to display the TabBar
starting on the left. If an AppBar
has a leading property I'd like to indent the starting position of the TabBar
to match it. Then on scroll, it would still pass through and not leave white area.
This is the code that I have that currently displays a TabBar
in the middle of the AppBar
:
AppBar(
bottom: TabBar(
isScrollable: true,
tabs: state.sortedStreets.keys.map(
(String key) => Tab(
text: key.toUpperCase(),
),
).toList(),
),
);
You can use Align Widget to align the tabs of the TabBar to left, which will be the child of PreferredSize.
This worked for me:
bottom: PreferredSize(
preferredSize: Size.fromHeight(40),
///Note: Here I assigned 40 according to me. You can adjust this size acoording to your purpose.
child: Align(
alignment: Alignment.centerLeft,
child: TabBar(
isScrollable: true,
tabs: state.sortedStreets.keys.map(
(String key) => Tab(
text: key.toUpperCase(),
),
).toList(),
),
),
),
In case you only need TabBar in body you can remove the PreferredSize Widget.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With