Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.1.2

- fix: the endless loop can still happen if you switch between tabs quickly and time it perfectly while still loading gifs.

[All Code Changes](https://github.com/Flyclops/tenor_flutter/compare/0.1.1...0.1.2)

## 0.1.1

- fix: if you switch tabs very quickly before the initial gif fetch then you will get stuck in an endless loop and crash the app.
Expand Down
15 changes: 7 additions & 8 deletions lib/src/components/tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,8 @@ class _TenorTabViewState extends State<TenorTabView>

// Wait for a frame so that we can ensure that `scrollController` is attached
WidgetsBinding.instance.addPostFrameCallback((_) async {
while (_scrollController.position.extentAfter == 0) {
// Stop trying to load more and exit the loop if:
// 1 - the selected tab has changed
// 2 - there are no more gifs to load
if (_tabProvider.selectedTab != tab || !_hasMoreGifs) return;

await _loadMore();
if (_scrollController.position.extentAfter == 0) {
_loadMore(fillScrollableArea: true);
}
});
}
Expand Down Expand Up @@ -306,7 +301,7 @@ class _TenorTabViewState extends State<TenorTabView>
}
}

Future<void> _loadMore() async {
Future<void> _loadMore({bool fillScrollableArea = false}) async {
// 1 - prevent non active tabs from loading more
// 2 - if it's loading don't load more
// 3 - if there are no more gifs to load, don't load more
Expand Down Expand Up @@ -367,6 +362,10 @@ class _TenorTabViewState extends State<TenorTabView>
_isLoading = false;
rethrow;
}

if (fillScrollableArea && _scrollController.position.extentAfter == 0) {
Future.microtask(() => _loadMore(fillScrollableArea: true));
}
}

// Return selected gif
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: tenor_flutter
version: 0.1.1
version: 0.1.2
description: An opinionated yet customizable Flutter package for searching and selecting from a list of GIFs/Stickers from the Tenor GIF search API.
homepage: https://github.com/flyclops
repository: https://github.com/flyclops/tenor_flutter
Expand Down