I's working on an app that retrieves data from a flutter database but I'm having issues with my fetch queries.
Fetch method:
void _fetchUserData() async {
// Assuming you store the current user session and it has a valid token
final user = Supabase.instance.client.auth.currentUser;
if (user != null) {
setState(() {
_userId = user.id; // Set the user ID
});
// Fetch the user profile data
final response = await Supabase.instance.client
.from('user_profiles')
.select()
.eq('id', user.id)
.single();
if (response.data != null) {
// Update the state with fetched data
setState(() {
// Assuming 'date_of_birth', 'gender', and 'id_number' are columns in your 'profiles' table
_dobController.text = response.data['date_of_birth'];
_genderController.text = response.data['gender'];
_idController.text = response.data['id_number'];
});
} else if (response.error != null) {
// Handle the error
_showSnackBar(response.error.message);
}
}
}
Error messages: The getter 'data' isn't defined for the type 'Map<String, dynamic>'. Try importing the library that defines 'data', correcting the name to the name of an existing getter, or defining a getter or field named 'data'.
The getter 'error' isn't defined for the type 'Map<String, dynamic>'. Try importing the library that defines 'error', correcting the name to the name of an existing getter, or defining a getter or field named 'error'.
I'm not sure why I'm getting this error message as I've seen many examples using response.data and response.error. Is there a fix for this or an alternative method of getting the response?