Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cupertino_ui/lib/src/bottom_tab_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget {
width: 0.0, // 0.0 means one physical pixel
),
),
}) : assert(items.length >= 2, "Tabs need at least 2 items to conform to Apple's HIG"),
}) : assert(items.length > 0, 'CupertinoTabBar requires at least one tab.'),
Comment thread
dkwingsmt marked this conversation as resolved.
assert(0 <= currentIndex && currentIndex < items.length),
assert(height >= 0.0);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changelog: |
- Allows `CupertinoTabBar` to contain a single item.
version: patch
28 changes: 17 additions & 11 deletions packages/cupertino_ui/test/bottom_tab_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,32 @@ Future<void> pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async
}

Future<void> main() async {
testWidgets('Need at least 2 tabs', (WidgetTester tester) async {
await expectLater(
() => pumpWidgetWithBoilerplate(
tester,
CupertinoTabBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(CupertinoIcons.search), label: 'Tab 1'),
],
),
),
test('CupertinoTabBar requires at least one item', () {
expect(
() => CupertinoTabBar(items: const <BottomNavigationBarItem>[]),
throwsA(
isAssertionError.having(
(AssertionError error) => error.toString(),
'.toString()',
contains('items.length'),
contains('CupertinoTabBar requires at least one tab.'),
),
),
);
});

testWidgets('CupertinoTabBar supports one item', (WidgetTester tester) async {
await pumpWidgetWithBoilerplate(
tester,
CupertinoTabBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(CupertinoIcons.search), label: 'Tab 1'),
],
),
);

expect(find.byType(CupertinoTabBar), findsOneWidget);
});

testWidgets('Active and inactive colors', (WidgetTester tester) async {
await pumpWidgetWithBoilerplate(
tester,
Expand Down
Loading