Unverified Commit 4c1045c0 authored by Anthony Mansour's avatar Anthony Mansour Committed by GitHub

Fixed preferredSize getter in TabBar (#41299)

parent 1903ce01
...@@ -753,7 +753,7 @@ class TabBar extends StatefulWidget implements PreferredSizeWidget { ...@@ -753,7 +753,7 @@ class TabBar extends StatefulWidget implements PreferredSizeWidget {
for (final Widget item in tabs) { for (final Widget item in tabs) {
if (item is Tab) { if (item is Tab) {
final Tab tab = item; final Tab tab = item;
if (tab.text != null && tab.icon != null) if ((tab.text != null || tab.child != null) && tab.icon != null)
return Size.fromHeight(_kTextAndIconTabHeight + indicatorWeight); return Size.fromHeight(_kTextAndIconTabHeight + indicatorWeight);
} }
} }
......
...@@ -2459,4 +2459,20 @@ void main() { ...@@ -2459,4 +2459,20 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('No tabs'), findsOneWidget); expect(find.text('No tabs'), findsOneWidget);
}); });
testWidgets('TabBar expands vertically to accommodate the Icon and child Text() pair the same amount it would expand for Icon and text pair.', (WidgetTester tester) async {
const double indicatorWeight = 2.0;
const List<Widget> tabListWithText = <Widget>[
Tab(icon: Icon(Icons.notifications), text: 'Test'),
];
const List<Widget> tabListWithTextChild = <Widget>[
Tab(icon: Icon(Icons.notifications), child: Text('Test')),
];
const TabBar tabBarWithText = TabBar(tabs: tabListWithText, indicatorWeight: indicatorWeight,);
const TabBar tabBarWithTextChild = TabBar(tabs: tabListWithTextChild, indicatorWeight: indicatorWeight,);
expect(tabBarWithText.preferredSize, tabBarWithTextChild.preferredSize);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment