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

Unified Diff: sky/sdk/lib/widgets/scrollable_list.dart

Issue 1223863003: Factor ScrollableList out of StockList (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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_list.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/scrollable_list.dart
diff --git a/sky/sdk/lib/widgets/scrollable_list.dart b/sky/sdk/lib/widgets/scrollable_list.dart
new file mode 100644
index 0000000000000000000000000000000000000000..667c0e2817f78f79ad1e8fdab27ecaae868789a5
--- /dev/null
+++ b/sky/sdk/lib/widgets/scrollable_list.dart
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium 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 'dart:math' as math;
+
+import 'fixed_height_scrollable.dart';
+import 'basic.dart';
+
+class ScrollableList<T> extends FixedHeightScrollable {
+ ScrollableList({
+ String key,
+ this.items,
+ this.itemBuilder,
+ double itemHeight,
+ EdgeDims padding
+ }) : super(key: key, itemHeight: itemHeight, padding: padding);
+
+ List<T> items;
+ Function itemBuilder;
Hixie 2015/07/07 16:49:56 Builder, not Function.
+
+ int get itemCount => items.length;
Hixie 2015/07/07 16:49:56 move itemCount below syncFields()
+
+ void syncFields(ScrollableList<T> source) {
+ items = source.items;
+ itemBuilder = source.itemBuilder;
+ super.syncFields(source);
+ }
+
+ Iterable<Widget> _buildItems(int start, int count) sync* {
Hixie 2015/07/07 16:49:56 This is very fancy but I'm skeptical it's either t
+ int end = math.min(start + count, items.length);
+ for (int i = start; i < end; ++i)
+ yield itemBuilder(items[i]);
+ }
+
+ List<Widget> buildItems(int start, int count) {
+ return _buildItems(start, count).toList(growable: false);
hansmuller 2015/07/07 17:07:12 Doesn't apply toList() here eliminate the advantag
+ }
+}
« no previous file with comments | « sky/sdk/example/stocks/lib/stock_list.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698