title: Flutter Riverpod : return 2 stream with StreamProvider
body: <p>I have music player application using package <a href="https://pub.dev/packages/assets_audio_player" rel="nofollow noreferrer">Asset Audio Player</a> and <a href="https://riverpod.dev/" rel="nofollow noreferrer">Flutter Riverpod</a> as State Management. I want listen 2 things stream :</p>
  <ol>
  <li>Listen current duration of song</li>
  <li>Listen current song played</li>
  </ol>
  <pre><code>final currentSongPosition = StreamProvider.autoDispose&lt;Map&lt;String, dynamic&gt;&gt;((ref) async* {
    final AssetsAudioPlayer player = ref.watch(globalAudioPlayers).state;
    ref.onDispose(() =&gt; player.dispose());
  
    final Stream&lt;double&gt; _first = player.currentPosition.map((event) =&gt; event.inSeconds.toDouble());
    final Stream&lt;double&gt; _second =
        player.current.map((event) =&gt; event?.audio.duration.inSeconds.toDouble() ?? 0.0);
  
    final maps = {};
    maps['currentDuration'] = _first;
    maps['maxDurationSong'] = _second;
    return maps; &lt;&lt; Error The return type 'Map&lt;dynamic, dynamic&gt;' isn't a 'Stream&lt;Map&lt;String, dynamic&gt;&gt;', as required by the closure's context.
  });
  </code></pre>
  <p>How can i return 2 stream into 1 <code>StreamProvider</code> then i can simply using like this :</p>
  <pre><code>Consumer(
                builder: (_, watch, __) {
                 
                  final _currentSong = watch(currentSongPosition);
  
                  return _currentSong.when(
                    data: (value) {
                      final _currentDuration = value['currentDuration'] as double;
                      final _maxDuration = value['maxDuration'] as double;
                      return Text('Current : $_currentDuration, Max :$_maxDuration');
                    },
                    loading: () =&gt; Center(child: CircularProgressIndicator()),
                    error: (error, stackTrace) =&gt; Text('Error When Playing Song'),
                  );
                 
                },
              ),
  </code></pre>