I have created as Realm object and got it connected to MongoDB Atlas.
In Flutter StreamBuilder widget the stream parameter takes RealmResults.changes as a stream and it works.
StreamBuilder<MyObject>(
stream: RealmResults.changes, //works
builder: (context, snapshot) => ()
),
But if StreamProvider is used, the create parameter which requires a stream does not accept RealmResults.changes as a stream.
StreamProvider<MyObject>(
initialData: MyObject(),
create: (context) => RealmResults.changes, //error
child: Scaffold()
)
Here the error shown undelined in red is: The return type 'Stream<RealmResultsChanges<MyObject>>' isn't a 'Stream<MyObject>?', as required by the closure's context. I am confused, can anyone help me. Thanks