Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |