Chromium Code Reviews| 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
|
| + } |
| +} |