Home > Back-end >  The argument type 'Stream<SequenceState?>' can't be assigned to the parameter t
The argument type 'Stream<SequenceState?>' can't be assigned to the parameter t

Time:07-13

I want to come up with an audio player using flutter however the _audioPlayer.sequenceStateStream is giving the above error. How can I resolve this error?

Code:

final AudioPlayer _audioPlayer;

@override
Widget build(BuildContext context) {
    return Row(
     mainAxisSize: MainAxisSize.min,
      children: [
        StreamBuilder<bool>(
          stream: _audioPlayer.shuffleModeEnabledStream,
          builder: (context, snapshot) {
            return _shuffleButton(context, snapshot.data ?? false);
          },
        ),
        StreamBuilder<SequenceState>(
          stream: _audioPlayer.sequenceStateStream,
          builder: (_, __) {
            return _previousButton();
          },
        ),

CodePudding user response:

Try to add a ? after SequenceState:

  final AudioPlayer _audioPlayer;

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        StreamBuilder<bool>(
          stream: _audioPlayer.shuffleModeEnabledStream,
          builder: (context, snapshot) {
            return _shuffleButton(context, snapshot.data ?? false);
          },
        ),
        StreamBuilder<SequenceState?>(
          stream: _audioPlayer.sequenceStateStream,
          builder: (_, __) {
            return _previousButton();
          },
        ),
  • Related