Fix for issue #75518 - ListTile.divideTiles throws error if empty list is passed when null-safety enabled (#75522)

This commit is contained in:
Miguel Beltran
2021-02-09 18:41:12 +01:00
committed by GitHub
parent 44d7bd3550
commit 72f15e9bdb
2 changed files with 8 additions and 0 deletions

View File

@@ -982,6 +982,9 @@ class ListTile extends StatelessWidget {
assert(tiles != null);
assert(color != null || context != null);
if (tiles.isEmpty)
return;
final Iterator<Widget> iterator = tiles.iterator;
final bool isNotEmpty = iterator.moveNext();

View File

@@ -252,6 +252,11 @@ void main() {
expect(find.text('third'), findsOneWidget);
});
testWidgets('ListTile.divideTiles with empty list', (WidgetTester tester) async {
final Iterable<Widget> output = ListTile.divideTiles(tiles: <Widget>[], color: Colors.grey);
expect(output, isEmpty);
});
testWidgets('ListTileTheme', (WidgetTester tester) async {
final Key titleKey = UniqueKey();
final Key subtitleKey = UniqueKey();