Custom Function - pulling boolean from Supabase into FF

I am trying to create a custom function to check if someone is a committee member. I pass the uuid of the user into the custom function and then I try to pull the record which is a Supabase boolean field from the view but I get an error.

A value of type 'PostgrestTransformBuilder<dynamic>' can't be returned from the function 'isCommittee' because it has a return type of 'String'.

Obviously, I have tried a number of methods to get this to work, the below is a combination.

Code:

import 'dart:convert';
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:timeago/timeago.dart' as timeago;
import '/flutter_flow/lat_lng.dart';
import '/flutter_flow/place.dart';
import '/flutter_flow/uploaded_file.dart';
import '/flutter_flow/custom_functions.dart';
import '/backend/supabase/supabase.dart';
import '/auth/supabase_auth/auth_util.dart';

String isCommittee(String uuid) {
  /// MODIFY CODE ONLY BELOW THIS LINE

  final supabase = SupaFlow.client;
  try {
    var response = supabase
        .from('public.user_list')
        .select('committee')
        .eq('user_id', uuid)
        .single();

    return response;
    // Check if the response contains the 'committee' field
    if (response == 'true') {
      // Extract the 'committee' field from the response
      dynamic committeeField = response;

      // Check if committeeField is not null and is a string before returning
      if (committeeField != null && committeeField is String) {
        return committeeField;
      }
    }

    return 'DefaultStringValue'; // Default value if 'committee' is not present or not a string
  } catch (e) {
    print('An error occurred: $e');
    return 'Error';
  }

  /// MODIFY CODE ONLY ABOVE THIS LINE
}

Any ideas?

1
3 replies