createChatUserProfile function

Future<void> createChatUserProfile({
  1. required String userIdentifier,
  2. required File selectedImage,
  3. required String username,
})

Implementation

Future<void> createChatUserProfile({required String userIdentifier, required File selectedImage,required String username}) async {
     final imagePath='/$userIdentifier/profile';
    final imageExtension=selectedImage.path.split('.').last.toLowerCase();
     final imageBytes=await selectedImage.readAsBytes();
    await supabaseStorage.uploadBinary(imagePath, imageBytes,
    fileOptions: FileOptions(
     contentType: 'image/$imageExtension'
    )
    );
    final imageUrl=supabaseStorage.getPublicUrl(imagePath);
    // Perform the update with a where clause to match the correct profile
       await supabaseProfiles.insert({
                              'username':username,
                              'id':userIdentifier,
                              'avatar_url':imageUrl
                             })
          .eq('id', userIdentifier);  // Add condition to update where id matches the Firebase UID
  }