HeavenOSK / flutter_swipable_stack

A widget for stacking cards, which users can swipe horizontally and vertically with beautiful animations like Tinder UI.
https://pub.dev/packages/swipable_stack
MIT License
117 stars 48 forks source link

Video Card #62

Open haidernaqvi87 opened 2 years ago

haidernaqvi87 commented 2 years ago

Hello team, If I placed a short video instead of Image, then when I swipe the video it keeps on playing with sound. That means it is not destroying the video widget. Any workaround?

maeddin commented 2 years ago

@haidernaqvi87 Can't you stop the video the moment it is swiped? Depending on what widget you use to play the video, there should be a controller that lets you stop the video. (Usually video_player)

mghali1 commented 1 year ago

Hello @haidernaqvi87,

You can use the onWillMoveNext: (index, swipeDirection) param. This function is called before performing a swipe. It will return true or false depending on whether or not you want to allow the movement. Anyways, before returning a true or a false, stop the video from playing.

Now if you're worried about the memory because the video not being destroyed, I guess you can do the following. In the onSwipeCompleted: (index, direction) param, send a function that will nullify or clear or the video from the list. yourList[index] = null; and reset the statesetState({}). It will rebuild, but nothing will change on the user's side the controller's index is index + 1 (cause you swiped already). Just make sure that on the card builder, you cater for the null.