ringtone_set 0.0.2

Flutter Android iOS

Flutter Plugin for setting devices default ringtone or notification sound.

example/lib/main.dart

import 'dart:io';

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

import 'package:flutter/services.dart';
import 'package:ringtone_set/ringtone_set.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {}

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Builder(builder: (context) {
          return Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: <Widget>[
                FlatButton(
                    onPressed: () async {
                      String result;
                      try {
                        result = await RingtoneSet.setRingtone("h1.mp3");
                      } on PlatformException {
                        result = 'Error';
                      }
                      var snackbar = SnackBar(content: Text("$result"));
                      Scaffold.of(context).showSnackBar(snackbar);
                    },
                    child: Text("Hey Ringtone")),
                FlatButton(
                    onPressed: () async {
                      String result;
                      try {
                        result = await RingtoneSet.setNotification("h1.mp3");
                      } on PlatformException {
                        result = 'Error';
                      }
                      var snackbar = SnackBar(content: Text("$result"));
                      Scaffold.of(context).showSnackBar(snackbar);
                    },
                    child: Text("Hey Notification")),
                FlatButton(
                    onPressed: () async {
                      String result;
                      try {
                        result = await RingtoneSet.setRingtone("untitled.mp3");
                      } on PlatformException {
                        result = 'Error';
                      }
                      var snackbar = SnackBar(content: Text("$result"));
                      Scaffold.of(context).showSnackBar(snackbar);
                    },
                    child: Text("Untitled Ringtone")),
                FlatButton(
                    onPressed: () async {
                      String result;
                      try {
                        result =
                            await RingtoneSet.setNotification("untitled.mp3");
                      } on PlatformException {
                        result = 'Error';
                      }
                      var snackbar = SnackBar(content: Text("$result"));
                      Scaffold.of(context).showSnackBar(snackbar);
                    },
                    child: Text("Untitled Notification")),
              ],
            ),
          );
        }),
      ),
    );
  }
}
3
likes
80
pub points
49%
popularity

Flutter Plugin for setting devices default ringtone or notification sound.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

r.acar1999@gmail.com

License

BSD (LICENSE)

Dependencies

flutter, path_provider

More

Packages that depend on ringtone_set