1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-06 11:41:26 +00:00

Flutter 3.29 beta (#2571)

This commit is contained in:
Eric Windmill
2025-02-12 18:08:01 -05:00
committed by GitHub
parent d62c784789
commit 719fd72c38
685 changed files with 76244 additions and 53721 deletions

View File

@@ -21,22 +21,19 @@ Future<ItemPage> fetchPage(int startingIndex) async {
// If the [startingIndex] is beyond the bounds of the catalog, an
// empty page will be returned.
if (startingIndex > catalogLength) {
return ItemPage(
items: [],
startingIndex: startingIndex,
hasNext: false,
);
return ItemPage(items: [], startingIndex: startingIndex, hasNext: false);
}
// The page of items is generated here.
return ItemPage(
items: List.generate(
min(itemsPerPage, catalogLength - startingIndex),
(index) => Item(
color: Colors.primaries[index % Colors.primaries.length],
name: 'Color #${startingIndex + index}',
price: 50 + (index * 42) % 200,
)),
min(itemsPerPage, catalogLength - startingIndex),
(index) => Item(
color: Colors.primaries[index % Colors.primaries.length],
name: 'Color #${startingIndex + index}',
price: 50 + (index * 42) % 200,
),
),
startingIndex: startingIndex,
// Returns `false` if we've reached the [catalogLength].
hasNext: startingIndex + itemsPerPage < catalogLength,

View File

@@ -11,11 +11,7 @@ class Item {
final String name;
Item({
required this.color,
required this.name,
required this.price,
});
Item({required this.color, required this.name, required this.price});
Item.loading() : this(color: Colors.grey, name: '...', price: 0);