Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2037)

Unified Diff: sky/sdk/example/stocks/lib/stock_list.dart

Issue 1219933004: Make it harder to forget itemCount for FixedHeightScrollable (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address ian's comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/example/stocks/lib/stock_home.dart ('k') | sky/sdk/lib/widgets/fixed_height_scrollable.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/example/stocks/lib/stock_list.dart
diff --git a/sky/sdk/example/stocks/lib/stock_list.dart b/sky/sdk/example/stocks/lib/stock_list.dart
index 4b36783d186d25f5a0cd5920b5794a8a234cc844..6fd63806fb8c4b1640a4ca5f2ca1024f6bba6860 100644
--- a/sky/sdk/example/stocks/lib/stock_list.dart
+++ b/sky/sdk/example/stocks/lib/stock_list.dart
@@ -10,28 +10,20 @@ import 'stock_row.dart';
class Stocklist extends FixedHeightScrollable {
- Stocklist({
- String key,
- this.stocks,
- this.query
- }) : super(itemHeight: StockRow.kHeight, key: key);
+ Stocklist({ String key, this.stocks })
+ : super(itemHeight: StockRow.kHeight, key: key);
- String query;
List<Stock> stocks;
+ int get itemCount => stocks.length;
+
void syncFields(Stocklist source) {
- query = source.query;
stocks = source.stocks;
super.syncFields(source);
}
List<Widget> buildItems(int start, int count) {
- var filteredStocks = stocks.where((stock) {
- return query == null ||
- stock.symbol.contains(new RegExp(query, caseSensitive: false));
- });
- itemCount = filteredStocks.length;
- return filteredStocks
+ return stocks
.skip(start)
.take(count)
.map((stock) => new StockRow(stock: stock))
« no previous file with comments | « sky/sdk/example/stocks/lib/stock_home.dart ('k') | sky/sdk/lib/widgets/fixed_height_scrollable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698