Skip to content

Instantly share code, notes, and snippets.

@diegoveloper
Created October 6, 2021 15:28
Show Gist options
  • Save diegoveloper/f863bf15ac49247a859f3da908045b15 to your computer and use it in GitHub Desktop.
Save diegoveloper/f863bf15ac49247a859f3da908045b15 to your computer and use it in GitHub Desktop.
class ListViewComparison extends StatelessWidget {
const ListViewComparison({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final items = List.generate(10000, (index) => _MyItem(index: index));
return true
? ListView(
children: items,
)
: ListView.builder(
itemCount: 10000,
itemBuilder: (context, index) {
return _MyItem(index: index);
});
}
}
class _MyItem extends StatelessWidget {
const _MyItem({Key? key, required this.index}) : super(key: key);
final int index;
@override
Widget build(BuildContext context) {
print('Building ... $index');
return Container(
height: 100,
child: FittedBox(
child: Text(index.toString()),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment