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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « sky/sdk/example/stocks/lib/stock_list.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 import 'dart:math' as math;
6
7 import 'fixed_height_scrollable.dart';
8 import 'basic.dart';
9
10 class ScrollableList<T> extends FixedHeightScrollable {
11 ScrollableList({
12 String key,
13 this.items,
14 this.itemBuilder,
15 double itemHeight,
16 EdgeDims padding
17 }) : super(key: key, itemHeight: itemHeight, padding: padding);
18
19 List<T> items;
20 Function itemBuilder;
Hixie 2015/07/07 16:49:56 Builder, not Function.
21
22 int get itemCount => items.length;
Hixie 2015/07/07 16:49:56 move itemCount below syncFields()
23
24 void syncFields(ScrollableList<T> source) {
25 items = source.items;
26 itemBuilder = source.itemBuilder;
27 super.syncFields(source);
28 }
29
30 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
31 int end = math.min(start + count, items.length);
32 for (int i = start; i < end; ++i)
33 yield itemBuilder(items[i]);
34 }
35
36 List<Widget> buildItems(int start, int count) {
37 return _buildItems(start, count).toList(growable: false);
hansmuller 2015/07/07 17:07:12 Doesn't apply toList() here eliminate the advantag
38 }
39 }
OLDNEW
« 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