Repository navigation
TabBar.height adds a gap between the AppBar.toolbar and AppBar.bottom #156200
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Use case
If we add a smaller height to TabBar, E.G:
AppBar(
bottom: const TabBar(
tabs: [
Tab(
text: 'Profile',
height: 30,
),
Tab(
text: 'Appearance',
height: 30,
),
],
),
It adds a gap between the `AppBar` `toolbar` and the `bottom`:
And without the height specified on the Tab, it has no gap:
I don't want the gap. So i want this:
Proposal
Ideally we should be able to control the padding between them but i found just adding mainAxisSize: MainAxisSize.min, below to app_bar.dart at least removed the gap entirely which is better than mandatory gap:
if (widget.bottom != null) {
appBar = Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: toolbarHeight),
child: appBar,
),
),
if (widget.bottomOpacity == 1.0)
widget.bottom!
else
Opacity(
opacity: const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.bottomOpacity),
child: widget.bottom,
),
],
);
Adding this between them gave the padding desired: SizedBox(height: 5), so ideally you would add bottomSpacer as a parameter to customise: SizedBox(height: bottomSpacer), or make it EdgeInsets and wrap the bottom with it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Type
Projects
- StatusShow more project fieldsDone (PR merged)
Activity
TahaTesser commentedon Oct 22, 2024
@Piinks
This is by design. When the tabs height is less than the default
_kTabHeightthen it defaults to the value of_kTabHeight(46 pixels)flutter/packages/flutter/lib/src/material/tabs.dart
Lines 1290 to 1298 in 71ddc68
If we want to change this behavior, to avoid breaking change we would need to some sort of parameter.
Piinks commentedon Oct 22, 2024
Ah right, thanks for taking a look. Should we add to the docs that TabBars cannot be less than 46 pixels in height?
TahaTesser commentedon Oct 22, 2024
+1 and I remember folks using
PreferredSizefor a custom tab bar. It can be leveraged to get a smaller than default tab bar.Update `Tab.height` parameter doc for tab height lower than default (#…
Update `Tab.height` parameter doc for tab height lower than default (f…
github-actions commentedon Nov 7, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.