Need help querying Supabase complex Query

Database & APIs

I'm currently querying a supabase function for a complex query where i use multiple 'and' search parameters.

this all seems to be working and providing me the desired outcome.

THe only thing i cant seem to get working is parsing the data into datatype or supabase rows.

i have tried multiple processing and it always give me different errors.


so i am querying a list of 10000 NFT's based on attributes.

i get correct response in json format.

No matter what i get errors like this :



this is the response in my 'network' on calling the function

  
Future<List<NftStruct>> searchNFTs(
  String? skincolorFilter,
  String? eyecolorFilter,
  String? skintypeFilter,
  String? baseFilter,
  String? animalFilter,
  String sortBy,
  String sortDirection,
  int limit,
  int offset,
) async {
  final supabase = Supabase.instance.client;

  // Call the RPC function and pass the necessary filters and sort options
  final response = await supabase.rpc('search_nfts', params: {
    'animal_filter': animalFilter?.isEmpty == true ? null : animalFilter,
    'eyecolor_filter': eyecolorFilter?.isEmpty == true ? null : eyecolorFilter,
    'skincolor_filter':
        skincolorFilter?.isEmpty == true ? null : skincolorFilter,
    'skintype_filter': skintypeFilter?.isEmpty == true ? null : skintypeFilter,
    'base_filter': baseFilter?.isEmpty == true ? null : baseFilter,
    'sort_by': sortBy,
    'sort_direction': sortDirection,
    'limit_val': limit,
    'offset_val': offset,
  });

  // Handle any error in the Supabase response
  if (response.error != null) {
    throw Exception('Supabase Error: ${response.error!.message}');
  }

  // Parse and return the response data as a list of NftStructs
  final nftList = (response.data as List<dynamic>).map((nftData) {
    return NftStruct(
      nft: nftData['nft'] as int,
      rarity: nftData['rarity'] as int,
      skincolor: nftData['skincolor'] as String,
      eyecolor: nftData['eyecolor'] as String,
      skintype: nftData['skintype'] as String,
      base: nftData['base'] as String,
      animal: nftData['animal'] as String,
      url: nftData['url'] as String,
    );
  }).toList();

  return nftList;
}
What have you tried so far?

multiple changes to processing of the data, all with similar errors it's frying my head

Did you check FlutterFlow's Documentation for this topic?
No
3
2 replies