1
0
mirror of https://github.com/flutter/samples.git synced 2026-03-25 05:41:41 +00:00
Files
samples/infinite_list/lib/src/item_tile.dart
Brett Morgan 58bc5d7a58 Deps update, utilize super.key (#1265)
* Deps update, utilize `super.key`

* `flutter format`
2022-05-13 12:31:56 -07:00

54 lines
1.5 KiB
Dart

// Copyright 2020 The Chromium Authors. All rights reserved.
// 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 'api/item.dart';
/// This is the widget responsible for building the item in the list,
/// once we have the actual data [item].
class ItemTile extends StatelessWidget {
final Item item;
const ItemTile({required this.item, super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ListTile(
leading: AspectRatio(
aspectRatio: 1,
child: Container(
color: item.color,
),
),
title: Text(item.name, style: Theme.of(context).textTheme.headline6),
trailing: Text('\$ ${(item.price / 100).toStringAsFixed(2)}'),
),
);
}
}
/// 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({super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ListTile(
leading: const AspectRatio(
aspectRatio: 1,
child: Placeholder(),
),
title: Text('...', style: Theme.of(context).textTheme.headline6),
trailing: const Text('\$ ...'),
),
);
}
}