flutter_media_notification 1.0.0

Flutter Media Notification #

Pub Package GitHub Issues GitHub Forks GitHub Stars GitHub License

Flutter Media Notification is a package that you can use it to show you media notification and control streaming media beyond your 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.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: () => MediaNotification.showNotification(
                    title: 'Title', author: 'Song author'),
                child: Text('Update notification'),
                onPressed: () => MediaNotification.showNotification(
                    title: 'New Title',
                    author: 'New Song author',
                    isPlaying: false),
                child: Text('Hide notification'),
                onPressed: MediaNotification.hideNotification,
              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.0.0

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 Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (meta).


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