I am making a music player app in Flutter and I am not able to find any way to make a widget or something that is displayed in the notification tray and can play or pause the music. Is it even possible to achieve this in flutter and if yes, how can I do that? Thanks in advance.
Asked
Active
Viewed 7,742 times
7

amit.flutter
- 883
- 9
- 27

Ayush Singh
- 1,409
- 3
- 19
- 31
-
can you any code or image that make easy to understand what you want. – Viren V Varasadiya Aug 27 '18 at 18:25
-
Like the musix match music controller. – Ayush Singh Aug 27 '18 at 18:28
-
I want to make something like that for my flutter app. – Ayush Singh Aug 27 '18 at 18:29
-
how to do this same for video player? @AyushSingh you have any idea? – amit.flutter Jan 13 '23 at 05:34
1 Answers
3
Because of the way android notifications work, you can only really customize them with android code (for now at least). So unfortunately, you're going to have to write some native code here.
The actual notification part is the exact same as directly with android in this case, so you can simply look that up. Here's a start though.
The other part to this is that you need to communicate between your flutter code and the native code which handles the notification. To do so, you need to use Platform Channels. Platform channels are things you register so that you can send data back and forth between java/kotlin/objc/swift and dart, in the form of events or 'method calls'. The docs do a better job than me of explaining how to use them.

rmtmckenzie
- 37,718
- 9
- 112
- 99