How can I differentiate between Providers that provide the same class

Issue

I have four providers, that all provide the Instances of Challenge class, to the same Widget.
They are different challenges, but I don’t know how to differentiate between the providers, so i wondered, if it’s possible to give names to the providers.

Solution

Actually, you can’t, this is the biggest drawback of provider, you can use riverpod instead, it’s from the same author, but it has some advantages over a normal provider.

this is what the author of both provider and riverpod sais.

It makes the provider pattern more flexible, which allows supporting commonly requested features like:
Being able to have multiple providers of the same type.

Answered By – Adnan Alshami

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *