Compare commits

...

2 Commits

2 changed files with 14 additions and 6 deletions

View File

@@ -1159,7 +1159,7 @@ class ComicListState extends State<ComicList> {
if (res.data.isEmpty) { if (res.data.isEmpty) {
setState(() { setState(() {
_data[page] = const []; _data[page] = const [];
_maxPage = page; _maxPage ??= page;
}); });
} else { } else {
setState(() { setState(() {
@@ -1282,8 +1282,8 @@ class ComicListState extends State<ComicList> {
], ],
); );
} }
if (_data[_page] == null) { if (_data[1] == null) {
_loadPage(_page); _loadPage(1);
return Column( return Column(
children: [ children: [
if (widget.errorLeading != null) widget.errorLeading!, if (widget.errorLeading != null) widget.errorLeading!,
@@ -1304,7 +1304,7 @@ class ComicListState extends State<ComicList> {
comics: _data.values.expand((element) => element).toList(), comics: _data.values.expand((element) => element).toList(),
menuBuilder: widget.menuBuilder, menuBuilder: widget.menuBuilder,
onLastItemBuild: () { onLastItemBuild: () {
if (_error == null && (_maxPage == null || _page < _maxPage!)) { if (_error == null && (_maxPage == null || _data.length < _maxPage!)) {
_loadPage(_data.length + 1); _loadPage(_data.length + 1);
} }
}, },
@@ -1334,7 +1334,7 @@ class ComicListState extends State<ComicList> {
], ],
).paddingHorizontal(16).paddingVertical(8), ).paddingHorizontal(16).paddingVertical(8),
) )
else if (_maxPage == null || _page < _maxPage!) else if (_maxPage == null || _data.length < _maxPage!)
const SliverListLoadingIndicator(), const SliverListLoadingIndicator(),
if (widget.trailingSliver != null) widget.trailingSliver!, if (widget.trailingSliver != null) widget.trailingSliver!,
], ],

View File

@@ -181,7 +181,15 @@ abstract class ImageDownloader {
} }
if (configs['onResponse'] is JSInvokable) { if (configs['onResponse'] is JSInvokable) {
buffer = (configs['onResponse'] as JSInvokable)([Uint8List.fromList(buffer)]); dynamic result = (configs['onResponse'] as JSInvokable)([Uint8List.fromList(buffer)]);
if (result is Future) {
result = await result;
}
if (result is List<int>) {
buffer = result;
} else {
throw "Error: Invalid onResponse result.";
}
(configs['onResponse'] as JSInvokable).free(); (configs['onResponse'] as JSInvokable).free();
} }