mirror of
https://github.com/flutter/samples.git
synced 2025-11-12 07:48:55 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -5,27 +5,32 @@
|
||||
import 'author.dart';
|
||||
import 'book.dart';
|
||||
|
||||
final libraryInstance = Library()
|
||||
..addBook(
|
||||
title: 'Left Hand of Darkness',
|
||||
authorName: 'Ursula K. Le Guin',
|
||||
isPopular: true,
|
||||
isNew: true)
|
||||
..addBook(
|
||||
title: 'Too Like the Lightning',
|
||||
authorName: 'Ada Palmer',
|
||||
isPopular: false,
|
||||
isNew: true)
|
||||
..addBook(
|
||||
title: 'Kindred',
|
||||
authorName: 'Octavia E. Butler',
|
||||
isPopular: true,
|
||||
isNew: false)
|
||||
..addBook(
|
||||
title: 'The Lathe of Heaven',
|
||||
authorName: 'Ursula K. Le Guin',
|
||||
isPopular: false,
|
||||
isNew: false);
|
||||
final libraryInstance =
|
||||
Library()
|
||||
..addBook(
|
||||
title: 'Left Hand of Darkness',
|
||||
authorName: 'Ursula K. Le Guin',
|
||||
isPopular: true,
|
||||
isNew: true,
|
||||
)
|
||||
..addBook(
|
||||
title: 'Too Like the Lightning',
|
||||
authorName: 'Ada Palmer',
|
||||
isPopular: false,
|
||||
isNew: true,
|
||||
)
|
||||
..addBook(
|
||||
title: 'Kindred',
|
||||
authorName: 'Octavia E. Butler',
|
||||
isPopular: true,
|
||||
isNew: false,
|
||||
)
|
||||
..addBook(
|
||||
title: 'The Lathe of Heaven',
|
||||
authorName: 'Ursula K. Le Guin',
|
||||
isPopular: false,
|
||||
isNew: false,
|
||||
);
|
||||
|
||||
class Library {
|
||||
final List<Book> allBooks = [];
|
||||
@@ -55,11 +60,7 @@ class Library {
|
||||
return allBooks[int.parse(id)];
|
||||
}
|
||||
|
||||
List<Book> get popularBooks => [
|
||||
...allBooks.where((book) => book.isPopular),
|
||||
];
|
||||
List<Book> get popularBooks => [...allBooks.where((book) => book.isPopular)];
|
||||
|
||||
List<Book> get newBooks => [
|
||||
...allBooks.where((book) => book.isNew),
|
||||
];
|
||||
List<Book> get newBooks => [...allBooks.where((book) => book.isNew)];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user