Make sure that a NavigationBar doesn't crash in 0x0 environment#176731
Make sure that a NavigationBar doesn't crash in 0x0 environment#176731auto-submit[bot] merged 2 commits intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a test to ensure that the NavigationBar widget does not crash when placed in a 0x0 environment. The test verifies that when a NavigationBar is constrained to a zero size, it correctly reports its size as Size.zero and does not throw any exceptions during widget pumping.
| testWidgets('NavigationBar does not crash at zero area', (WidgetTester tester) async { | ||
| await tester.pumpWidget( | ||
| MaterialApp( | ||
| home: Center( | ||
| child: SizedBox.shrink( | ||
| child: NavigationBar( | ||
| destinations: const <Widget>[ | ||
| NavigationDestination(icon: Icon(Icons.add), label: 'X'), | ||
| NavigationDestination(icon: Icon(Icons.abc), label: 'Y'), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(NavigationBar)), Size.zero); | ||
| }); |
There was a problem hiding this comment.
This test case is a valuable addition for ensuring NavigationBar behaves correctly in a zero-sized environment. However, the pull request appears to only add the test but not the corresponding fix in NavigationBar itself.
Based on the PR's description, it's expected that a change in the widget's code is necessary to prevent a crash. Without this fix, this test is likely to fail.
Please add the necessary changes to navigation_bar.dart in this pull request to resolve the underlying issue.
dkwingsmt
left a comment
There was a problem hiding this comment.
Checklist:
- The test is in the correct file
- The test name goes “does not crash at zero area”
- The target widget is wrapped by
Center(or is fullscreen) - The target widget does not have an overlay, or the overlay is tested
- The target widget is expected to have a size of exactly
Size.zero
8d67c9c to
cc826dd
Compare
|
autosubmit label was removed for flutter/flutter/176731, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…ter#176731) This is my attempt to handle flutter#6537 for the NavigationBar widget. Co-authored-by: Tong Mu <[email protected]>
This is my attempt to handle #6537 for the NavigationBar widget.