Access a Supabase function through a custom action - RPC

Custom Code

I have a function in Supabase that returns a bunch of rows based on an input parameter - gid. I don't want to do it with API calls, as Flutterflow does not allow more than 2 API endpoints in both the free plan and the standard plan.

I ensured the Supabase function is working and producing a bunch of rows based on the input. I can't do a view in Supabase as there a complex logic so have to use a supabase function to code it. The function returns a customized results rather than a particular table output.

I have created a custom action with a remote procedure call to this supabase function in it. as you can see in the screenshot, I have json as return value. I am able to compile it without any issues. However, when i retrieve it in a listview on the FF screen, it is giving me null error.

Is json the right return value ? does it need to be a list? I tried datatype as suggested in another thread, i am not able to. Is there another return value , that i need to choose.

Is the return in the custom action correctly coded?

I have pasted the FF screens that shows how the custom action is called on page load, how the children are generated and how the individual fields within json is populated. hopefully this is clear. appreciate for your help in advance.

there is not much help in FF documentation or online.

What have you tried so far?
// Automatic FlutterFlow imports
import '/backend/supabase/supabase.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

Future<dynamic> getContestLeaderboard(int gid) async {
  // Add your function code here!

  try {
    final supabase = SupaFlow.client;
    final response =
        await supabase.rpc('get_contest_leaderboard', params: {'gameid': gid});
    //return response.data as VotesRow;
    //return VotesRow.fromJson(response.data);
    return response;
  } catch (e) {
    print('Exception:$e');
  }
}
Did you check FlutterFlow's Documentation for this topic?
Yes
2
1 reply