displayPlaybackSpeedOptions method

void displayPlaybackSpeedOptions()

Implementation

void displayPlaybackSpeedOptions(){
  List playbackSpeeds = [
    0.25,
    0.5,
    0.75,
    1.0,
    1.5,
    2.0
  ];

  showModalBottomSheet(
    context: context,
    builder: (BuildContext context) {
      return SingleChildScrollView(
        child: Column(
          children: [
            for(int i = 0; i < playbackSpeeds.length; i++)
            Container(
              margin: menuMainContainerButtonMargin,
              child: SizedBox(
                width: menuButtonWidth,
                child: currentPlaybackSpeed != playbackSpeeds[i] ?
                  ElevatedButton(
                    style: menuButtonStyle,
                    onPressed: (){
                      playerController.value.setPlaybackSpeed(playbackSpeeds[i]);
                      currentPlaybackSpeed = playbackSpeeds[i];
                      Navigator.of(context).pop();
                    },
                    child: Text('${playbackSpeeds[i]}')
                  )
                :
                  ElevatedButton.icon(
                    style: menuButtonStyle,
                    icon: const Icon(Icons.check),
                    onPressed: (){
                      playerController.value.setPlaybackSpeed(playbackSpeeds[i]);
                      Navigator.of(context).pop();
                    },
                    label: Text('${playbackSpeeds[i]}')
                  )
              )
                ),
          ],
        )
      );
    }
  );
}