mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Landing beta changes in master for the new stable release (#747)
This commit is contained in:
@@ -32,7 +32,7 @@ class MyHomePage extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: Text('Infinite List Sample'),
|
||||
),
|
||||
body: Selector<Catalog, int>(
|
||||
body: Selector<Catalog, int?>(
|
||||
// Selector is a widget from package:provider. It allows us to listen
|
||||
// to only one aspect of a provided value. In this case, we are only
|
||||
// listening to the catalog's `itemCount`, because that's all we need
|
||||
|
||||
@@ -12,9 +12,9 @@ class Item {
|
||||
final String name;
|
||||
|
||||
Item({
|
||||
@required this.color,
|
||||
@required this.name,
|
||||
@required this.price,
|
||||
required this.color,
|
||||
required this.name,
|
||||
required this.price,
|
||||
});
|
||||
|
||||
Item.loading() : this(color: Colors.grey, name: '...', price: 0);
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'item.dart';
|
||||
|
||||
const int itemsPerPage = 20;
|
||||
@@ -17,8 +14,8 @@ class ItemPage {
|
||||
final bool hasNext;
|
||||
|
||||
ItemPage({
|
||||
@required this.items,
|
||||
@required this.startingIndex,
|
||||
@required this.hasNext,
|
||||
required this.items,
|
||||
required this.startingIndex,
|
||||
required this.hasNext,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Catalog extends ChangeNotifier {
|
||||
|
||||
/// The size of the catalog. This is `null` at first, and only when the user
|
||||
/// reaches the end of the catalog, it will hold the actual number.
|
||||
int itemCount;
|
||||
int? itemCount;
|
||||
|
||||
/// After the catalog is disposed, we don't allow it to call
|
||||
/// [notifyListeners].
|
||||
@@ -62,7 +62,7 @@ class Catalog extends ChangeNotifier {
|
||||
|
||||
// If the corresponding page is already in memory, return immediately.
|
||||
if (_pages.containsKey(startingIndex)) {
|
||||
var item = _pages[startingIndex].items[index - startingIndex];
|
||||
var item = _pages[startingIndex]!.items[index - startingIndex];
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'api/item.dart';
|
||||
class ItemTile extends StatelessWidget {
|
||||
final Item item;
|
||||
|
||||
ItemTile({@required this.item, Key key}) : super(key: key);
|
||||
ItemTile({required this.item, Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -34,7 +34,7 @@ class ItemTile extends StatelessWidget {
|
||||
/// This is the widget responsible for building the "still loading" item
|
||||
/// in the list (represented with "..." and a crossed square).
|
||||
class LoadingItemTile extends StatelessWidget {
|
||||
const LoadingItemTile({Key key}) : super(key: key);
|
||||
const LoadingItemTile({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user