dxvid-pts / miniplayer

A lightweight flutter package to simplify the creation of a miniplayer.
https://pub.dev/packages/miniplayer
MIT License
107 stars 80 forks source link

feat: Add onDragDown to Miniplayer #33

Open Dr-Blank opened 6 months ago

Dr-Blank commented 6 months ago

the notifier is there, this just makes it possible to be supplied from parent like the height notifier.

Use case: Control the volume of the media player like youtube does.

dxvid-pts commented 6 months ago

Thank you for your contribution! Looking at this in retroperspective it makes more sense to add a callback function instead of a custom valuenotifier. Then call the callback by listening to the exisiting (private) notifier.

E.g Function onDragDown(double dragDownPercentage); to be able to use


Miniplayer(
    onDragDown: (percentage){
        ...
    },
);
Dr-Blank commented 6 months ago

Thank you for your contribution! Looking at this in retroperspective it makes more sense to add a callback function instead of a custom valuenotifier. Then call the callback by listening to the exisiting (private) notifier.

E.g Function onDragDown(double dragDownPercentage); to be able to use

Miniplayer(
    onDragDown: (percentage){
        ...
    },
);

sure, I can make the change

Dr-Blank commented 6 months ago

@dxvid-pts

I have made the changes. Please review.

dxvid-pts commented 6 months ago

Hi, the listener returned by .addListener needs to be disposed in onDispose (not disposing leads to memory leaks I think). Other than that it's good to go!

Dr-Blank commented 6 months ago

Hi, the listener returned by .addListener needs to be disposed in onDispose (not disposing leads to memory leaks I think). Other than that it's good to go!

good catch.

https://github.com/dxvid-pts/miniplayer/pull/33/commits/480f7933deaf0225ceb3a97162efca53610ba840 should fix this.

according to the docs disposing the notifier should only be done by the owner and doing so will remove any listeners, hence I did it this way since this notifier was created by this widget. please let me know if this is not what you had in mind.

...This method should only be called by the object's owner...
...and clears the listener list once it is called...
Dr-Blank commented 5 months ago

Hey @dxvid-pts, just checking in to see if there's anything I can do to help move things forward. It seems you might not have received my last message, so I wanted to make sure you get this one. No pressure at all—I understand how busy things can get, so feel free to ignore this if you're tied up. Thanks!