Fix minor glitch in Gallery
This commit is contained in:
parent
ff4b620d0d
commit
cea00d8e8f
1 changed files with 18 additions and 8 deletions
|
@ -72,6 +72,9 @@ class _GalleryState extends State<Gallery> {
|
|||
_saveScrollPosition();
|
||||
});
|
||||
});
|
||||
if (widget.asyncLoader == null) {
|
||||
_hasLoadedAll = true;
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -108,6 +111,7 @@ class _GalleryState extends State<Gallery> {
|
|||
return nothingToSeeHere;
|
||||
}
|
||||
_collateFiles();
|
||||
_logger.info("Collated length " + _collatedFiles.length.toString());
|
||||
_scrollController = ScrollController(
|
||||
initialScrollOffset: _scrollOffset,
|
||||
);
|
||||
|
@ -146,18 +150,23 @@ class _GalleryState extends State<Gallery> {
|
|||
// Eagerly load next batch
|
||||
_loadNextItems();
|
||||
}
|
||||
if (index == _collatedFiles.length) {
|
||||
if (_hasLoadedAll || widget.asyncLoader == null) {
|
||||
return Container();
|
||||
}
|
||||
return loadWidget;
|
||||
}
|
||||
var fileIndex = index;
|
||||
var fileIndex;
|
||||
if (widget.headerWidget != null) {
|
||||
if (index == 0) {
|
||||
return widget.headerWidget;
|
||||
}
|
||||
fileIndex--;
|
||||
fileIndex = index - 1;
|
||||
} else {
|
||||
fileIndex = index;
|
||||
}
|
||||
if (fileIndex == _collatedFiles.length) {
|
||||
if (widget.asyncLoader != null) {
|
||||
if (!_hasLoadedAll) {
|
||||
return loadWidget;
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fileIndex < 0 || fileIndex >= _collatedFiles.length) {
|
||||
return Container();
|
||||
|
@ -205,6 +214,7 @@ class _GalleryState extends State<Gallery> {
|
|||
}
|
||||
|
||||
Widget _getGallery(List<File> files) {
|
||||
_logger.info("Building gallery with " + files.length.toString());
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
|
|
Loading…
Add table
Reference in a new issue