flutter provider MultiProvider using StreamProvider flutter provider MultiProvider using StreamProvider dart dart

flutter provider MultiProvider using StreamProvider


The reason you are seeing your error is because the type parameter you are passing to StreamProvider<T> as T is not matching what you are returning to create.

In this case, you want to stream values of type List<Recipe>.
Therefore, you should also pass that for the generic type:

StreamProvider<List<Recipe>>.value(value: stream)

Where the stream is your List<Recipe> stream.


If Provider.of<List<Recipe>>(context) is returning null for you, it means that you have not added a value to the stream.

If you want to have something other than null before you stream emits a value, you can pass initialValue:

StreamProvider<List<Recipe>>.value(  value: stream,  initialValue: initialRecipes,)