Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

Change Provider enum to ProviderEnum in order to avoid name conflicts with riverpod #19

Closed
igoriuz opened this issue Jun 26, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@igoriuz
Copy link

igoriuz commented Jun 26, 2021

Feature request

Rename Provider enum

Is your feature request related to a problem? Please describe.

Using supabase with riverpod in the same class will raise an error since both uses the same class name.

Describe the solution you'd like

Rename "Provider" enum class to "ProviderEnum". I'll open a pull request asap.

Describe alternatives you've considered

Alternatively i could give an alias to one of the imports.. but this is

  1. annoying
  2. due to riverpods popularity it's likely that more users will have the same problem soon
  3. improve developer experience by avoiding this error in first place

Additional context

Current erorr message:

'Provider' isn't a function. (Documentation) Try correcting the name to match an existing function, or define a method or function named 'Provider'. The name 'Provider' is defined in the libraries 'package:gotrue/src/provider.dart' and 'package:riverpod/src/provider.dart'. (Documentation) Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.

@igoriuz igoriuz added the enhancement New feature or request label Jun 26, 2021
@igoriuz igoriuz mentioned this issue Jun 26, 2021
@dshukertjr
Copy link
Member

dshukertjr commented Jun 27, 2021

Hi @igoriuz !

Thank you so much for opening an issue and submitting a PR about naming conflict with Gotrue and Riverpod.

I understand your pain of having to use an alias every time you use Gotrue with Riverpod.

I found an interesting thread of naming conflicts between Flutter and another package. We did chat about this issue internally, but unfortunately naming conflict could occur between any packages, and we believe it is better to have solid intuitive API than to avoid naming conflicts and end up with none-ideal names. We just cannot keep changing symbol names every time there is a conflict with other packages.

So in order to use Riverpod and Gotrue together this would be the way to do it:

import 'package:gotrue/gotrue.dart' as gotrue;

final res = await gotrueClient.signIn(provider: gotrue.Provider.github);

Or with Supabase:

import 'package:supabase/supabase.dart' as supabase;

final res = await gotrueClient.signIn(provider: supabase.Provider.github);

I really do understand the pain, and this is probably is not the answer you wanted, but I hope you could understand. We appreciate your feedback, and please don't hesitate to let us know any thoughts that might come up in the future!

@igoriuz
Copy link
Author

igoriuz commented Jun 27, 2021

Thanks for your fast reply @dshukertjr

Alternatively developers can hide this class on either of these imports.. for e.g.

import 'package:supabase/supabase.dart' hide Provider

My last suggestion would be renaming it to OAuthProvider but i can live with it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants