stock_list.dart 1.01 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8
import 'package:flutter/material.dart';

import 'stock_data.dart';
import 'stock_row.dart';
9

10
class StockList extends StatelessWidget {
11
  const StockList({
12
    super.key,
13 14 15 16
    required this.stocks,
    required this.onOpen,
    required this.onShow,
    required this.onAction,
17
  });
18 19

  final List<Stock> stocks;
20
  final StockRowActionCallback onOpen;
21
  final StockRowActionCallback onShow;
22
  final StockRowActionCallback onAction;
23

24
  @override
25
  Widget build(BuildContext context) {
26
    return ListView.builder(
27
      key: const ValueKey<String>('stock-list'),
28
      itemExtent: StockRow.kHeight,
29 30
      itemCount: stocks.length,
      itemBuilder: (BuildContext context, int index) {
31
        return StockRow(
32
          stock: stocks[index],
33
          onPressed: onOpen,
34
          onDoubleTap: onShow,
35
          onLongPressed: onAction,
36
        );
37
      },
38 39 40
    );
  }
}