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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.2

- fix: freeze when you type just white space into the input field when categories are visible
- fix: infinite loading when you type just white space into emoji/stickers
- fix: cursor jumping to the end of the input if you type anywhere but the end

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

## 1.0.1

- chore: Add discontinued notice
Expand Down
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ analyzer:
linter:
rules:
require_trailing_commas: true

formatter:
trailing_commas: preserve
15 changes: 8 additions & 7 deletions lib/src/components/search_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class _TenorSearchFieldState extends State<TenorSearchField> {
_appBarProvider.addListener(_listenerQuery);

// Set Texfield Controller
_textEditingController = widget.searchFieldController ??
_textEditingController =
widget.searchFieldController ??
TextEditingController(
text: _appBarProvider.queryText,
);
Expand Down Expand Up @@ -202,8 +203,7 @@ class _TenorSearchFieldState extends State<TenorSearchField> {
left: 4,
child: Icon(
Icons.search,
color:
widget.style.hintStyle.color ?? const Color(0xFF8A8A86),
color: widget.style.hintStyle.color ?? const Color(0xFF8A8A86),
size: 22,
),
),
Expand All @@ -218,8 +218,7 @@ class _TenorSearchFieldState extends State<TenorSearchField> {
padding: const EdgeInsets.all(8),
child: Icon(
Icons.clear,
color: widget.style.hintStyle.color ??
const Color(0xFF8A8A86),
color: widget.style.hintStyle.color ?? const Color(0xFF8A8A86),
size: 20,
),
),
Expand All @@ -240,15 +239,17 @@ class _TenorSearchFieldState extends State<TenorSearchField> {
// when they focus the input, maximize viewing space
_sheetProvider.scrollController.animateTo(
_sheetProvider.maxExtent,
duration:
animationStyle?.duration ?? tenorDefaultAnimationStyle.duration!,
duration: animationStyle?.duration ?? tenorDefaultAnimationStyle.duration!,
curve: animationStyle?.curve ?? Curves.linear,
);
}
}

// listener query
void _listenerQuery() {
// Update only when it's different. IE you tap on a category. Otherwise the cursor will jump to the end.
if (_textEditingController.text == _appBarProvider.queryText) return;

_textEditingController.text = _appBarProvider.queryText;
}
}
54 changes: 31 additions & 23 deletions lib/src/components/tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class TenorTabView extends StatefulWidget {
String? pos,
int limit,
TenorCategory? category,
)? onLoad;
)?
onLoad;
final Function(TenorResult? gif)? onSelected;
final bool showCategories;
final TenorTabViewStyle style;
Expand All @@ -48,8 +49,8 @@ class TenorTabView extends StatefulWidget {
this.showCategories = false,
this.style = const TenorTabViewStyle(),
super.key,
}) : featuredCategory = featuredCategory ?? '📈 Featured',
gifsPerRow = gifsPerRow ?? 3;
}) : featuredCategory = featuredCategory ?? '📈 Featured',
gifsPerRow = gifsPerRow ?? 3;

@override
State<TenorTabView> createState() => _TenorTabViewState();
Expand Down Expand Up @@ -151,7 +152,7 @@ class _TenorTabViewState extends State<TenorTabView>
);
}

if (_appBarProvider.queryText.isEmpty &&
if (_appBarProvider.queryText.trim().isEmpty &&
_appBarProvider.selectedCategory == null &&
widget.showCategories) {
return Padding(
Expand Down Expand Up @@ -188,10 +189,10 @@ class _TenorTabViewState extends State<TenorTabView>
// Add safe area padding if `TenorAttributionType.poweredBy` is disabled
padding:
_tabProvider.attributionType == TenorAttributionType.poweredBy
? null
? EdgeInsets.zero
: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom,
),
bottom: MediaQuery.of(context).padding.bottom,
),
scrollDirection: _scrollDirection,
),
),
Expand All @@ -206,24 +207,24 @@ class _TenorTabViewState extends State<TenorTabView>
crossAxisCount: widget.gifsPerRow,
crossAxisSpacing: 8,
keyboardDismissBehavior: _appBarProvider.keyboardDismissBehavior,
itemBuilder: (ctx, idx) => ClipRRect(
borderRadius: BorderRadius.circular(8),
child: TenorSelectableGif(
backgroundColor: widget.style.mediaBackgroundColor,
onTap: (selectedResult) => _selectedGif(
selectedResult,
itemBuilder:
(ctx, idx) => ClipRRect(
borderRadius: BorderRadius.circular(8),
child: TenorSelectableGif(
backgroundColor: widget.style.mediaBackgroundColor,
onTap: (selectedResult) => _selectedGif(selectedResult),
result: _list[idx],
),
),
result: _list[idx],
),
),
itemCount: _list.length,
mainAxisSpacing: 8,
// Add safe area padding if `TenorAttributionType.poweredBy` is disabled
padding: _tabProvider.attributionType == TenorAttributionType.poweredBy
? null
: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom,
),
padding:
_tabProvider.attributionType == TenorAttributionType.poweredBy
? null
: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom,
),
scrollDirection: _scrollDirection,
),
);
Expand Down Expand Up @@ -332,7 +333,7 @@ class _TenorTabViewState extends State<TenorTabView>

if (widget.onLoad != null) {
final response = await widget.onLoad?.call(
_appBarProvider.queryText,
_appBarProvider.queryText.trim(),
offset,
requestLimit,
_appBarProvider.selectedCategory,
Expand Down Expand Up @@ -389,7 +390,8 @@ class _TenorTabViewState extends State<TenorTabView>
// if you scroll within a threshhold of the bottom of the screen, load more gifs
void _scrollControllerListener() {
// trending-gifs, etc
final customCategorySelected = _appBarProvider.selectedCategory != null &&
final customCategorySelected =
_appBarProvider.selectedCategory != null &&
_appBarProvider.queryText == '';

if (customCategorySelected ||
Expand All @@ -404,6 +406,12 @@ class _TenorTabViewState extends State<TenorTabView>

// When the text in the search input changes
void _appBarProviderListener() {
// Prevent searches with only spaces
if (_appBarProvider.queryText.isNotEmpty &&
_appBarProvider.queryText.trim().isEmpty) {
return;
}

setState(() {
_list = [];
_collection = null;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/providers/app_bar_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class TenorAppBarProvider with ChangeNotifier {
Duration debounce, {
required this.keyboardDismissBehavior,
TenorCategory? selectedCategory,
}) : _selectedCategory = selectedCategory,
super() {
}) : _selectedCategory = selectedCategory,
super() {
_queryText = queryText;
_debounce = debounce;
}
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: 1.0.1
version: 1.0.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