'Undefined name' error when using Supabase in Custom Action for Login with Discord

Custom Code

I'm trying to implement Discord login in my FlutterFlow app using Supabase as backend. To do this, I created a Custom Action and inserted the following Flutter code:

Future<void> signInWithDiscord() async {
  try {
    await Supabase.instance.client.auth.signInWithOAuth(Provider.discord);
  } catch (e) {
    print('Erro ao fazer login com Discord: $e');
  }
}

However, when trying to compile the Custom Action, I am getting the following errors:

  • Undefined name 'Supabase'. Try correcting the name to one that is defined, or defining the name. (Line [indicate the line in your code])

  • Undefined name 'Provider'. Try correcting the name to one that is defined, or defining the name. (Line [indicate the line in your code])

I have already configured the Supabase backend in my FlutterFlow project with the correct project URL and anonymous key.

What have you tried so far?
  1. I added the dependency supabase_flutter in pubspec.yaml from FlutterFlow, as per the instructions.

  2. I have checked and confirmed that my Supabase project URL and anonymous key are correct in FlutterFlow settings.

  3. I tried using different versions of the dependency supabase_flutter in pubspec.yaml.

  4. I saved the changes, closed and reopened FlutterFlow.

  5. I checked that there is only one import of the Supabase library in my Custom Action:import '/backend/supabase/supabase.dart';.

  6. I made sure there are no typos or indentation issues in the Custom Action code.

  7. I tried to run code generation in FlutterFlow.

Even after these attempts, the error persists. Has anyone faced a similar issue while using Supabase in Custom Actions in FlutterFlow? Is there any additional configuration or step that I might have missed?

Did you check FlutterFlow's Documentation for this topic?
Yes
1