From 84432a8c8bf969c05bb4f66ca910be4874112296 Mon Sep 17 00:00:00 2001 From: Aein1364 <126414962+Aein1364@users.noreply.github.com> Date: Sat, 15 Apr 2023 15:18:19 +0330 Subject: [PATCH] Update podcast_widgets.dart Refactoring the list view items so that whenever it is tapped, the desired file will be played and the timer will be reset, and also the selected index variable must be defined in the controller. --- lib/component/widgets/podcast_widgets.dart | 51 ++++++++++++++-------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/lib/component/widgets/podcast_widgets.dart b/lib/component/widgets/podcast_widgets.dart index c2afbbe..aa24cca 100644 --- a/lib/component/widgets/podcast_widgets.dart +++ b/lib/component/widgets/podcast_widgets.dart @@ -181,28 +181,43 @@ Widget fileList(TextTheme textheme) { shrinkWrap: true, itemBuilder: ((context, index) { return index < controller.podcastFileList.length - 1 - ? Padding( + ? Padding( padding: EdgeInsets.all(Dimens.small), - child: Row( + child: + + Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Row( - children: [ - ImageIcon( - Image.asset(Assets.icons.microphon.path).image, - color: SolidColors.seeMore, - ), - SizedBox( - width: Dimens.small, - ), - SizedBox( - width: Get.width / 1.5, - child: Text( - controller.podcastFileList[index].title!, - style: textheme.headline4, + GestureDetector( + onTap: () async { + + controller.startProgress(); + controller.selectedIndex.value = + index; + await controller.player.seek( + Duration.zero, + index: controller + .selectedIndex.value); + await controller.player.play(); + }, + child: Row( + children: [ + ImageIcon( + Image.asset(Assets.icons.microphon.path).image, + color: SolidColors.seeMore, ), - ), - ], + SizedBox( + width: Dimens.small, + ), + SizedBox( + width: Get.width / 1.5, + child: Text( + controller.podcastFileList[index].title!, + style: textheme.headline4, + ), + ), + ], + ), ), Text(controller.podcastFileList[index].lenght! + ":00") ],