blob: af37e15e368b30654c323a1018af6903b29de6ec [file] [log] [blame]
// Copyright 2013 The Flutter 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 '../data.dart';
/// The book list view.
class BookList extends StatelessWidget {
/// Creates an [BookList].
const BookList({
required this.books,
Key? key,
}) : super(key: key);
/// The list of books to be displayed.
final List<Book> books;
/// Called when the user taps a book.
final ValueChanged<Book>? onTap;
Widget build(BuildContext context) => ListView.builder(
itemCount: books.length,
itemBuilder: (BuildContext context, int index) => ListTile(
title: Text(
subtitle: Text(
onTap: onTap != null ? () => onTap!(books[index]) : null,