|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public class SliverChildListDelegate : SliverChildDelegate { |
|
|
|
static readonly Key _defaultNullKey = Key.key("SliverChildListDelegate##DefaultNullKey"); |
|
|
|
|
|
|
|
public SliverChildListDelegate( |
|
|
|
List<Widget> children, |
|
|
|
bool addAutomaticKeepAlives = true, |
|
|
|
|
|
|
this.children = children; |
|
|
|
this.addAutomaticKeepAlives = addAutomaticKeepAlives; |
|
|
|
this.addRepaintBoundaries = addRepaintBoundaries; |
|
|
|
_keyToIndex = new Dictionary<Key, int>(){{Key.key("null"), 0}}; |
|
|
|
_keyToIndex = new Dictionary<Key, int>{{_defaultNullKey, 0}}; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly bool addAutomaticKeepAlives; |
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
if (!_keyToIndex.ContainsKey(key)) { |
|
|
|
int index = _keyToIndex.getOrDefault(Key.key("null")); |
|
|
|
int index = _keyToIndex.getOrDefault(_defaultNullKey); |
|
|
|
if (child.key != Key.key("null")) { |
|
|
|
if (child.key != _defaultNullKey) { |
|
|
|
_keyToIndex[Key.key("null")] = index + 1; |
|
|
|
_keyToIndex[_defaultNullKey] = index + 1; |
|
|
|
_keyToIndex[Key.key("null")] = index; |
|
|
|
_keyToIndex[_defaultNullKey] = index; |
|
|
|
} else { |
|
|
|
return _keyToIndex[key]; |
|
|
|
} |
|
|
|
|
|
|
if (index < 0 || index >= children.Count) |
|
|
|
return null; |
|
|
|
Widget child = children[index]; |
|
|
|
Key key = child.key != null? new _SaltedValueKey(child.key) : null; |
|
|
|
|
|
|
|
"The sliver's children must not contain null values, but a null value was found at index $index" |
|
|
|
"The sliver's children must not contain null values, but a null value was found at index $index" |
|
|
|
|
|
|
|
Key key = child.key != null? new _SaltedValueKey(child.key) : null; |
|
|
|
if (addRepaintBoundaries) |
|
|
|
child = new RepaintBoundary(child: child); |
|
|
|
if (addAutomaticKeepAlives) |
|
|
|