sectionInfoForPosition method
通过position获取对应的sectionInfo
Implementation
@override
SectionInfo? sectionInfoForPosition(int position) {
if(_totalCount == null) return null;
if(position == 0 && shouldExistHeader()){
return _headerSectionInfo;
}
if(position == totalCount - 1 && shouldExistFooter()){
return _footerSectionInfo;
}
if (_sectionInfos.length == 0) return null;
var info = _sectionInfos[0];
for (int i = 1; i < _sectionInfos.length; i++) {
var sectionInfo = _sectionInfos[i];
if (sectionInfo.sectionBegin > position) {
break;
} else {
info = sectionInfo;
}
}
return info;
}