findIndexByKey method Null safety

  1. @override
int? findIndexByKey(
  1. Key key
)
override

Find index of child element with associated key.

This will be called during performRebuild in SliverMultiBoxAdaptorElement to check if a child has moved to a different position. It should return the index of the child element with associated key, null if not found.

Implementation

@override
int? findIndexByKey(Key key) {
  if (findChildIndexCallback == null)
    return null;
  assert(key != null);
  final Key childKey;
  if (key is _SaltedValueKey) {
    final _SaltedValueKey saltedValueKey = key;
    childKey = saltedValueKey.value;
  } else {
    childKey = key;
  }
  return findChildIndexCallback!(childKey);
}