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:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user