flutter_media_notification 1.2.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 84

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:

MediaNotification.hideNotification();

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', () {
      setState();
    });
    
  • set listener for pause action:
    MediaNotification.setListener('pause', () {
      setState();
    });
    
  • set listener for next action:
    MediaNotification.setListener('next', () {
      setState();
    });
    
    • set listener for previous action:
    MediaNotification.setListener('prev', () {
      setState();
    });
    
  • set listener for selecting on notification:
    MediaNotification.setListener('select', () {
      setState();
    });
    

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

example/lib/main.dart

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

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

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

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

  @override
  void initState() {
    super.initState();

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

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

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

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

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

  @override
  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>[
              FlatButton(
                  child: Text('Show notification'),
                  onPressed: () {
                    MediaNotification.showNotification(
                        title: 'Title', author: 'Song author');
                    setState(() => status = 'play');
                  }),
              FlatButton(
                  child: Text('Update notification'),
                  onPressed: () {
                    MediaNotification.showNotification(
                        title: 'New Title',
                        author: 'New Song author',
                        isPlaying: false);
                    setState(() => status = 'pause');
                  }),
              FlatButton(
                  child: Text('Hide notification'),
                  onPressed: () {
                    MediaNotification.hideNotification();
                    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:


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
69
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

We analyzed this package on Oct 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

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.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test