mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Fixed preferredSize getter in TabBar (#41299)
This commit is contained in:
parent
1903ce012e
commit
4c1045c0f8
|
@ -753,7 +753,7 @@ class TabBar extends StatefulWidget implements PreferredSizeWidget {
|
|||
for (final Widget item in tabs) {
|
||||
if (item is Tab) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2459,4 +2459,20 @@ void main() {
|
|||
await tester.pumpAndSettle();
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue