Make sure that a SwitchListTile doesn't crash in 0x0 environment (#178069)
This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the SwitchListTile
widget.
Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
diff --git a/packages/flutter/test/material/switch_list_tile_test.dart b/packages/flutter/test/material/switch_list_tile_test.dart
index 4e3aad3..3aef967 100644
--- a/packages/flutter/test/material/switch_list_tile_test.dart
+++ b/packages/flutter/test/material/switch_list_tile_test.dart
@@ -2194,4 +2194,17 @@
);
expect(title.text.style!.color, Colors.yellow[500]);
});
+
+ testWidgets('SwitchListTile does not crash at zero area', (WidgetTester tester) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Center(
+ child: SizedBox.shrink(child: SwitchListTile(value: true, onChanged: (_) {})),
+ ),
+ ),
+ ),
+ );
+ expect(tester.getSize(find.byType(SwitchListTile)), Size.zero);
+ });
}