loadAssetsFromSearching static method

Future<Map<String, double>> loadAssetsFromSearching(
  1. int offset,
  2. String value,
  3. Store<GiphyState> store
)

Implementation

static Future<Map<String, double>> loadAssetsFromSearching(int offset, String value, Store<GiphyState> store) async{
  if(value == ''){
    return loadAssetsFromTrending(offset, store);
  }
  else{
    try{
      Map<String, double> _displayAssets = {};
      GiphyCollection collection = await store.state.giphyClient!.search(value, offset: offset, limit: store.state.pageSize, rating: GiphyRating.pg13).then((value) {
        return value;
      });
      List<GiphyGif>? _list = collection.data;
      if(offset == 0){
        store.dispatch(Reset());
      }
      if(_list != null){
        for(GiphyGif _gif in _list){
          String _url = _gif.images!.fixedWidth.url;
          double _displaySize = double.parse(_gif.images!.fixedWidthDownsampled!.width)/double.parse(_gif.images!.fixedWidthDownsampled!.height);
          _displayAssets[_url] = _displaySize;
        }
      }
      return _displayAssets;
    }
    catch(e){
      return {};
    }
  }
}