-
-
Notifications
You must be signed in to change notification settings - Fork 504
Closed
Description
Hi Ryan .
in streamBuilder I want to use my provider like:
StreamBuilder<ScreenState>(
stream: Rx.combineLatest3<List<MediaItem>, MediaItem,
PlaybackState, ScreenState>(
AudioService.queueStream,
AudioService.currentMediaItemStream,
AudioService.playbackStateStream,
(queue, mediaItem, playbackState) =>
ScreenState(queue, mediaItem, playbackState)),
builder: (context, snapshot) {
final screenState = snapshot.data;
Provider.of<AudioServiceSubscription>(context,
listen: false)
.setQueue(screenState?.queue);
Provider.of<AudioServiceSubscription>(context,
listen: false)
.setMediaItem(screenState?.mediaItem);
Provider.of<AudioServiceSubscription>(context,
listen: false)
.setPlaybackState(screenState?.playbackState);
return _palyer();
},
),
because I want to show state of audio in diffrent routes so I have to use Provider.
but as I run the app I get
setState() or markNeedsBuild() called during build.
I think I give this error because I am using provider in builder of StreamBuilder and I can't use it there.
in audioplayers , it uses
StreamSubscription _playerStateSubscription
and in initState uses
_audioPlayer.onPlayerStateChanged.listen((state) {
if (!mounted) return;
setState(() {
_audioPlayerState = state;
});
});
which in there instead of setState I can use my provider .
but I don't have idea how to use provider in combo of streamBuilder ?
is it not better to use audioPlayers approach (using StreamSubscription) , because it is more flexible ?
or is there an alternative or better approach to use proviser ?
also excuse me Ryan , I ask you many questions in your plugin.
Thanks alot .
Metadata
Metadata
Assignees
Labels
No labels