flutter_media_notification 1.2.6

Flutter Media Notification #

Pub Package GitHub Issues GitHub Forks GitHub Stars GitHub License

IOS not implemented #

I'm looking for mac to develop ios side, so it takes time.

Flutter Media Notification helps you to show your media notification and control streaming media beyond your flutter app.

This library is open source, stable and AndroidX supported. Development happens on GitHub/flutter_media_notification. Feel free to report issues or create a pull-request there. An example within a music player shares on GitHub/flutter_music. If you found this project helpful or you learned something from the source code and want to thank me, consider donating me Here.

The package is hosted on dart packages.

Tutorial #

Installation #

Follow the installation instructions on dart packages.

Import the package into your Dart code using:

import 'package:flutter_media_notification/flutter_media_notification.dart';

Showing and Hiding #

To show notification when your music is playing use the function:

MediaNotification.showNotification(title: 'Title', author: 'Song author');

To show notification when your music is pausing use the function:

MediaNotification.showNotification(title: 'Title', author: 'Song author', isPlaying : false);

To hide notification use the function:


Setting a Listener #

To setting a listener for an action use these setListener in initState() of main.dart to control your media beyond your app:

  • set listener for play action:
    MediaNotification.setListener('play', () {
  • set listener for pause action:
    MediaNotification.setListener('pause', () {
  • set listener for next action:
    MediaNotification.setListener('next', () {
    • set listener for previous action:
    MediaNotification.setListener('prev', () {
  • set listener for selecting on notification:
    MediaNotification.setListener('select', () {

License #

The MIT License, see LICENSE.

Changelog #

1.2.6 #

  • startForegroundService is replaced by registrar.context().startService caused a bug

1.2.5 #

  • adding media style notification
  • notification now is a service

1.0.0 #

  • some code improvement
  • adding readme.md
  • adding docs

0.0.2 #

  • edit dependency and AndroidX supported

0.0.1 #

  • add package to pub.dev


import 'package:flutter/material.dart';
import 'package:flutter_media_notification/flutter_media_notification.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  String status = 'hidden';

  void initState() {

    MediaNotification.setListener('pause', () {
      setState(() => status = 'pause');

    MediaNotification.setListener('play', () {
      setState(() => status = 'play');

    MediaNotification.setListener('next', () {});

    MediaNotification.setListener('prev', () {});

    MediaNotification.setListener('select', () {});

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        body: new Center(
            child: Container(
          height: 250.0,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: <Widget>[
                  child: Text('Show notification'),
                  onPressed: () {
                        title: 'Title', author: 'Song author');
                    setState(() => status = 'play');
                  child: Text('Update notification'),
                  onPressed: () {
                        title: 'New Title',
                        author: 'New Song author',
                        isPlaying: false);
                    setState(() => status = 'pause');
                  child: Text('Hide notification'),
                  onPressed: () {
                    setState(() => status = 'hidden');
              Text('Status: ' + status)

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_media_notification: ^1.2.6

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_media_notification/flutter_media_notification.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies