Hi all,
Having fun with Flutterflow and supabase. I would like to create a function or custom action that will receive the 'authenticated user' 'user id' as a parameter which then looks for that particular user in a table called users within supabase and then returns the supabase row with that users data.
I keep getting an error when trying to return the value as a row. As I am still learning flutter, I have hit a big of a road block. I am guessing I need another class? Any help greatly appreciated? Thank you
Code below:
// 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!
import 'package:supabase_flutter/supabase_flutter.dart';
Future<UsersRow?> returnUserRowFromAuthenticatedUser(String userUUID) async {
// return a supabase row from the users table when the authenticated user reference is provided
// Initialize Supabase client
await Supabase.initialize(
url: '',
anonKey:
',
);
final supabase = Supabase.instance.client;
// Query the users table for the authenticated user reference
final response = await supabase
.from('users')
.select('id')
.eq('user_uuid', userUUID)
.execute();
// Check if the query was successful
if (response.error != null) {
throw response.error!;
}
//return response;
}