stock_list.dart 990 Bytes
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({ Key key, this.stocks, this.onOpen, this.onShow, this.onAction }) : super(key: key);
12 13

  final List<Stock> stocks;
14
  final StockRowActionCallback onOpen;
15
  final StockRowActionCallback onShow;
16
  final StockRowActionCallback onAction;
17

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