@@ -31,7 +31,8 @@ class TenorTabView extends StatefulWidget {
3131 String ? pos,
3232 int limit,
3333 TenorCategory ? category,
34- )? onLoad;
34+ )?
35+ onLoad;
3536 final Function (TenorResult ? gif)? onSelected;
3637 final bool showCategories;
3738 final TenorTabViewStyle style;
@@ -48,8 +49,8 @@ class TenorTabView extends StatefulWidget {
4849 this .showCategories = false ,
4950 this .style = const TenorTabViewStyle (),
5051 super .key,
51- }) : featuredCategory = featuredCategory ?? '📈 Featured' ,
52- gifsPerRow = gifsPerRow ?? 3 ;
52+ }) : featuredCategory = featuredCategory ?? '📈 Featured' ,
53+ gifsPerRow = gifsPerRow ?? 3 ;
5354
5455 @override
5556 State <TenorTabView > createState () => _TenorTabViewState ();
@@ -151,7 +152,7 @@ class _TenorTabViewState extends State<TenorTabView>
151152 );
152153 }
153154
154- if (_appBarProvider.queryText.isEmpty &&
155+ if (_appBarProvider.queryText.trim (). isEmpty &&
155156 _appBarProvider.selectedCategory == null &&
156157 widget.showCategories) {
157158 return Padding (
@@ -188,10 +189,10 @@ class _TenorTabViewState extends State<TenorTabView>
188189 // Add safe area padding if `TenorAttributionType.poweredBy` is disabled
189190 padding:
190191 _tabProvider.attributionType == TenorAttributionType .poweredBy
191- ? null
192+ ? EdgeInsets .zero
192193 : EdgeInsets .only (
193- bottom: MediaQuery .of (context).padding.bottom,
194- ),
194+ bottom: MediaQuery .of (context).padding.bottom,
195+ ),
195196 scrollDirection: _scrollDirection,
196197 ),
197198 ),
@@ -206,24 +207,24 @@ class _TenorTabViewState extends State<TenorTabView>
206207 crossAxisCount: widget.gifsPerRow,
207208 crossAxisSpacing: 8 ,
208209 keyboardDismissBehavior: _appBarProvider.keyboardDismissBehavior,
209- itemBuilder: (ctx, idx) => ClipRRect (
210- borderRadius: BorderRadius .circular (8 ),
211- child: TenorSelectableGif (
212- backgroundColor: widget.style.mediaBackgroundColor,
213- onTap: (selectedResult) => _selectedGif (
214- selectedResult,
210+ itemBuilder:
211+ (ctx, idx) => ClipRRect (
212+ borderRadius: BorderRadius .circular (8 ),
213+ child: TenorSelectableGif (
214+ backgroundColor: widget.style.mediaBackgroundColor,
215+ onTap: (selectedResult) => _selectedGif (selectedResult),
216+ result: _list[idx],
217+ ),
215218 ),
216- result: _list[idx],
217- ),
218- ),
219219 itemCount: _list.length,
220220 mainAxisSpacing: 8 ,
221221 // Add safe area padding if `TenorAttributionType.poweredBy` is disabled
222- padding: _tabProvider.attributionType == TenorAttributionType .poweredBy
223- ? null
224- : EdgeInsets .only (
225- bottom: MediaQuery .of (context).padding.bottom,
226- ),
222+ padding:
223+ _tabProvider.attributionType == TenorAttributionType .poweredBy
224+ ? null
225+ : EdgeInsets .only (
226+ bottom: MediaQuery .of (context).padding.bottom,
227+ ),
227228 scrollDirection: _scrollDirection,
228229 ),
229230 );
@@ -332,7 +333,7 @@ class _TenorTabViewState extends State<TenorTabView>
332333
333334 if (widget.onLoad != null ) {
334335 final response = await widget.onLoad? .call (
335- _appBarProvider.queryText,
336+ _appBarProvider.queryText. trim () ,
336337 offset,
337338 requestLimit,
338339 _appBarProvider.selectedCategory,
@@ -389,7 +390,8 @@ class _TenorTabViewState extends State<TenorTabView>
389390 // if you scroll within a threshhold of the bottom of the screen, load more gifs
390391 void _scrollControllerListener () {
391392 // trending-gifs, etc
392- final customCategorySelected = _appBarProvider.selectedCategory != null &&
393+ final customCategorySelected =
394+ _appBarProvider.selectedCategory != null &&
393395 _appBarProvider.queryText == '' ;
394396
395397 if (customCategorySelected ||
@@ -404,6 +406,12 @@ class _TenorTabViewState extends State<TenorTabView>
404406
405407 // When the text in the search input changes
406408 void _appBarProviderListener () {
409+ // Prevent searches with only spaces
410+ if (_appBarProvider.queryText.isNotEmpty &&
411+ _appBarProvider.queryText.trim ().isEmpty) {
412+ return ;
413+ }
414+
407415 setState (() {
408416 _list = [];
409417 _collection = null ;
0 commit comments