flauto 3.0.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

Flauto #

pub version

This plugin provides simple recorder and player functionalities for both `android` and `ios` platforms. This only supports default file extension for each platform. This plugin handles file from remote url. This plugin can handle playback stream from native (To sync exact time with bridging).

Free Read #

Medium Blog

Getting Started #

For help getting started with Flutter, view our online documentation.

Install #

Add flauto as a dependency in pubspec.yaml. The actual beta version is flauto: ^3.0.0+2 For help on adding as a dependency, view the documentation.
Add permission_handler as a dependency in pubspec.yaml. Refer to here for help.
If you need ffmpeg, add flutter_ffmpeg as a dependency in pubspec.yaml. Refer to here for help.

The sources are here.

  • branch stable is the actual flutter_sound 2.1.1
  • branch beta is the new plugin with advance features (V 3.0.0)
  • branch master is just for the project development and not to be used.
dependencies:
  flutter:
    sdk: flutter
  flauto: ^3.0.0+2
  permission_handler: ^4.4.0

# Comment out the following line if flutter_ffmpeg is not needed
  flutter_ffmpeg: ^0.2.10

Post Installation #

On iOS you need to add a usage description to info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>This sample uses the microphone to record your speech and convert it to text.</string>
<key>UIBackgroundModes</key>
<array>
	<string>audio</string>
</array>

On Android you need to add a permission to AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Migration Guide #

To migrate to 3.0.0 you must migrate your Android app to Android X by following the Migrating to AndroidX Guide.

Methods #

FuncParamReturnDescription
initializevoidInitializes the media player and all the callbacks for the player and the recorder. This procedure is implicitely called during the FlutterSound constructor. So you probably will not use this function yourself.
releaseMediaPlayervoidResets the media player and cleans up the device resources. This must be called when the player is no longer needed.
setSubscriptionDurationdouble secString messageSet subscription timer in seconds. Default is 0.010 if not using this method.
startRecorderString uri, int sampleRate, int numChannels, t_CODEC codecString uriStart recording. This will return uri used.
stopRecorderString messageStop recording.
startPlayerString fileUri, t_CODEC codec, whenFinished()Starts playing the file at the given URI.
startPlayerFromBufferUint8List dataBuffer, t_CODEC codec, whenFinished()String messageStart playing using a buffer encoded with the given codec
stopPlayerString messageStop playing.
pausePlayerString messagePause playing.
resumePlayerString messageResume playing.
seekToPlayerint milliSecs position to goToString messageSeek audio to selected position in seconds. Parameter should be less than audio duration to correctly placed.
iosSetCategorySESSION_CATEGORY, SESSION_MODE, optionsBooleanSet the session category on iOS.
androidAudioFocusRequestint focusGainBooleanDefine the Android Focus request to use in subsequent requests to get audio focus
setActivebool enabledBooleanRequest or Abandon the audio focus

Subscriptions #

SubscriptionReturnDescription
onRecorderStateChanged<RecordStatus>Able to listen to subscription when recorder starts.
onPlayerStateChanged<PlayStatus>Able to listen to subscription when player starts.

Default uri path #

When uri path is not set during the function call in startRecorder or startPlayer, records are saved/read to/from a temporary directory depending on the platform.

Codec compatibility #

Actually, the following codecs are supported by flutter_sound:

AACOGG/OpusCAF/OpusMP3OGG/VorbisPCM
iOS encoderYesYesYesNoNoNo
iOS decoderYesYesYesYesNoYes
Android encoderYesNoNoNoNoNo
Android decoderYesYesNoYesYesYes

This table will eventually be upgrated when more codecs will be added.

Usage #

Creating instance.

In your view/page/dialog widget's State class, create an instance of FlutterSound.

FlutterSound flutterSound = new FlutterSound();

Starting recorder with listener.

Future<String> result = await flutterSound.startRecorder(codec: t_CODEC.CODEC_AAC,);

result.then(path) {
	print('startRecorder: $path');

	_recorderSubscription = flutterSound.onRecorderStateChanged.listen((e) {
	DateTime date = new DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
	String txt = DateFormat('mm:ss:SS', 'en_US').format(date);
	});
}

The recorded file will be stored in a temporary directory. If you want to take your own path specify it like below. We are using path_provider in below so you may have to install it.

Directory tempDir = await getTemporaryDirectory();
File outputFile = await File ('${tempDir.path}/flutter_sound-tmp.aac');
String path = await flutterSound.startRecorder(outputFile.path, codec: t_CODEC.CODEC_AAC,);

Actually on iOS, you can choose from three encoders :

  • AAC (this is the default)
  • CAF/OPUS
  • OGG/OPUS

Recently, Apple added a support for encoding with the standard OPUS codec. Unfortunatly, Apple encapsulates its data in its own proprietary envelope : CAF. This is really stupid, this is Apple. If you need to record with regular OGG/OPUS you must add flutter_ffmpeg to your dependencies. Please, look to the flutter_ffmpeg plugin README for instructions for how to include this plugin into your app

To encode with OPUS you do the following :

await flutterSound.startRecorder(foot.path, codec: t_CODEC.CODEC_OPUS,)

On Android the OPUS codec is not yet supported by flutter_sound Recorder. (But Player is OK on Android)

Stop recorder

Future<String> result = await flutterSound.stopRecorder();

result.then(value) {
	print('stopRecorder: $value');

	if (_recorderSubscription != null) {
		_recorderSubscription.cancel();
		_recorderSubscription = null;
	}
}

You MUST ensure that the recorder has been stopped when your widget is detached from the ui. Overload your widget's dispose() method to stop the recorder when your widget is disposed.

@override
void dispose() {
	flutterSound.stopRecorder();
	super.dispose();
}

Start player

  • To start playback of a record from a URL call startPlayer.
  • To start playback of a record from a memory buffer call startPlayerFromBuffer

You can use both startPlayer or startPlayerFromBuffer to play a sound. The former takes in a URI that points to the file to play, while the latter takes in a buffer containing the file to play and the codec to decode that buffer.

Those two functions can have an optional parameter whenFinished:() for specifying what to do when the playback will be finished.

// An example audio file
final fileUri = "https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3";

String result = await flutterSound.startPlayer
	(
		fileUri,
		whenFinished: ()
		{
			 print( 'I hope you enjoyed listening to this song' );
		},
	);
// Load a local audio file and get it as a buffer
Uint8List buffer = (await rootBundle.load('samples/audio.mp3'))
    	.buffer
    	.asUint8List();

Future<String> result = await flutterSound.startPlayerFromBuffer
	(
		buffer,
		whenFinished: ()
		{
			 print( 'I hope you enjoyed listening to this song' );
		},
	);

You must wait for the return value to complete before attempting to add any listeners to ensure that the player has fully initialised.

Directory tempDir = await getTemporaryDirectory();
File fin = await File ('${tempDir.path}/flutter_sound-tmp.aac');
Future<String> result = await flutterSound.startPlayer(fin.path);

result.then(path) {
	print('startPlayer: $path');

	_playerSubscription = flutterSound.onPlayerStateChanged.listen((e) {
		if (e != null) {
			DateTime date = new DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
			String txt = DateFormat('mm:ss:SS', 'en_US').format(date);
			this.setState(() {
				this._isPlaying = true;
				this._playerTxt = txt.substring(0, 8);
			});
		}
	});
}

Start player from buffer

For playing data from a memory buffer instead of a file, you can do the following :

Uint8List buffer =  (await rootBundle.load(assetSample[_codec.index])).buffer.asUint8List();
String result = await flutterSound.startPlayerFromBuffer
	(
		buffer,
		codec: t_CODEC.CODEC_AAC,
		whenFinished: ()
		{
			 print( 'I hope you enjoyed listening to this song' );
		},
	);

Stop player

Future<String> result = await flutterSound.stopPlayer();

result.then(value) {
	print('stopPlayer: $result');
	if (_playerSubscription != null) {
		_playerSubscription.cancel();
		_playerSubscription = null;
	}
}

You MUST ensure that the player has been stopped when your widget is detached from the ui. Overload your widget's dispose() method to stop the player when your widget is disposed.

@override
void dispose() {
	flutterSound.stopPlayer();
	super.dispose();
}

Pause player

Future<String> result = await flutterSound.pausePlayer();

Resume player

Future<String> result = await flutterSound.resumePlayer();

iosSetCategory(), androidAudioFocusRequest() and setActive() - (optional)

Those three functions are optional. If you do not control the audio focus with the function setActive(), flutter_sound will require the audio focus each time the function startPlayer() is called and will release it when the sound is finished or when you call the function stopPlayer().

Before controling the focus with setActive() you must call iosSetCategory() on iOS or androidAudioFocusRequest() on Android. setActive() and androidAudioFocusRequest() are useful if you want to duck others. Those functions are probably called just once when the app starts. After calling this function, the caller is responsible for using correctly setActive() probably before startRecorder or startPlayer, and stopPlayer and stopRecorder.

You can refer to iOS documentation to understand the parameters needed for iosSetCategory() and to the Android documentation to understand the parameter needed for androidAudioFocusRequest().

Remark : those three functions does work on Android before SDK 26.

if (_duckOthers)
{
	if (Platform.isIOS)
		await flutterSound.iosSetCategory( t_IOS_SESSION_CATEGORY.PLAY_AND_RECORD, t_IOS_SESSION_MODE.DEFAULT, IOS_DUCK_OTHERS |  IOS_DEFAULT_TO_SPEAKER );
	else if (Platform.isAndroid)
		await flutterSound.a`ndroidAudioFocusRequest(` ANDROID_AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK );
} else
{
	if (Platform.isIOS)
		await flutterSound.iosSetCategory( t_IOS_SESSION_CATEGORY.PLAY_AND_RECORD, t_IOS_SESSION_MODE.DEFAULT, IOS_DEFAULT_TO_SPEAKER );
	else if (Platform.isAndroid)
		await flutterSound.androidAudioFocusRequest( ANDROID_AUDIOFOCUS_GAIN );
}
...
...
flutterSound.setActive(true); // Get the audio focus
flutterSound.startPlayer(aSound);
flutterSound.startPlayer(anotherSong);
flutterSound.setActive(false); // Release the audio focus

Seek player

To seek to a new location the player must already be playing.

String Future<result> = await flutterSound.seekToPlayer(miliSecs);

Setting subscription duration (Optional). 0.010 is default value when not set.

/// 0.01 is default
flutterSound.setSubscriptionDuration(0.01);

Setting volume.

/// 1.0 is default
/// Currently, volume can be changed when player is running. Try manage this right after player starts.
String path = await flutterSound.startPlayer(fileUri);
await flutterSound.setVolume(0.1);

Using the amplitude meter

The amplitude meter allows displaying a basic representation of the input sound. When enabled, it returns values ranging 0-120dB.

//// By default this option is disabled, you can enable it by calling
setDbLevelEnabled(true);
//// You can tweak the frequency of updates by calling this function (unit is seconds)
updateDbPeakProgress(0.8);
//// You need to subscribe in order to receive the value updates
_dbPeakSubscription = flutterSound.onRecorderDbPeakChanged.listen((value) {
  setState(() {
    this._dbLevel = value;
  });
});

Release the player

You MUST ensure that the player has been released when your widget is detached from the ui. Overload your widget's dispose() method to release the player when your widget is disposed. In this way you will reset the player and clean up the device resources, but the player will be no longer usable.

@override
void dispose() {
	flutterSound.releaseMediaPlayer();
	super.dispose();
}

Playing OGG/OPUS on iOS

To play OGG/OPUS on iOS you must add flutter_ffmpeg to your dependencies. Please, look to the flutter_ffmpeg plugin README for instructions for how to include this plugin into your app. Playing OGG/OPUS on Android is no problem, even without flutter_ffmpeg. Please notice that flutter_ffmpeg plugin on Android needs a minAndroidSdk 16 (or later) if you use the LTS Release, but minAndroidSdk 24 (or later) if you use the Main Release.

Flauto #

Flauto is a new flutter_sound module which is able to show controls on the lock screen. Using Flauto is very simple : just use the Flauto constructor instead of the regular FlutterSound.

flutterSound = Flauto();

You must startPlayerFromTrack to play a sound. This function takes in 1 required argument and 3 optional arguments:

  • a Track, which is the track that the player is going to play;
  • whenFinished:() : A call back function for specifying what to do when the song is finished
  • onSkipBackward:(), A call back function for specifying what to do when the user press the skip-backward button on the lock screen
  • onSkipForward:(), A call back function for specifying what to do when the user press the skip-forward button on the lock screen
path = await flauto.startPlayerFromTrack
(
	track,
	whenFinished: ( )
	{
		print( 'I hope you enjoyed listening to this song' );
	},

	onSkipBackward: ( )
	{
		print( 'Skip backward' );
		stopPlayer( );
		startPlayer( );
	},
	onSkipForward: ( )
	{
		print( 'Skip forward' );
		stopPlayer( );
		startPlayer( );
	},

);

Create a Track object

In order to play a sound when you initialized the player with the audio player features, you must create a Track object to pass to startPlayerFromTrack.

The Track class is provided by the flutter_sound package. Its constructor takes in 1 required argument and 3 optional arguments:

  • trackPath (required): a String representing the path that points to the audio file to play. This must be provided if dataBuffer is null, but you cannot provide both;
  • dataBuffer (required): a Uint8List, a buffer that contains an audio file. This must be provided if trackPath is null, but you cannot provide both;
  • trackTitle: the String to display in the notification as the title of the track;
  • trackAuthor the String to display in the notification as the name of the author of the track;
  • albumArtUrl a String representing the URL that points to the image to display in the notification as album art.
  • or albumArtAsset : the name of an asset to show in the nofitication
// Create with the path to the audio file
Track track = new Track(
	trackPath: "https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3", // An example audio file
        trackTitle: "Track Title",
        trackAuthor: "Track Author",
        albumArtUrl: "https://file-examples.com/wp-content/uploads/2017/10/file_example_PNG_1MB.png", // An example image
);

// Load a local audio file and get it as a buffer
Uint8List buffer = (await rootBundle.load('samples/audio.mp3'))
    	.buffer
    	.asUint8List();
// Create with the buffer
Track track = new Track(
	dataBuffer: buffer,
        trackTitle: "Track Title",
        trackAuthor: "Track Author",
        albumArtUrl: "https://file-examples.com/wp-content/uploads/2017/10/file_example_PNG_1MB.png", // An example image
);

TODO #

  • [ ] Seeking example in Example project
  • [x] Volume Control
  • [x] Sync timing for recorder callback handler

DEBUG #

When you face below error,

* What went wrong:
A problem occurred evaluating project ':app'.
> versionCode not found. Define flutter.versionCode in the local.properties file.

Please add below to your example/android/local.properties file.

flutter.versionName=1.0.0
flutter.versionCode=1
flutter.buildMode=debug

Help Maintenance #

I've been maintaining quite many repos these days and burning out slowly. If you could help me cheer up, buying me a cup of coffee will make my life really happy and get much energy out of it. <br/> Buy Me A Coffee Paypal

3.0.0 #

  • Module flauto for controlling flutter_sound from the lock-screen
  • API to control the audiofocus
  • API to set the audio-category (i.e. duck-others)
  • AndroidX and Android embbeded-V2 support
  • Add a parameter to startPlayer to specify a callback when the song is finished

2.1.1 #

  • Amazon billing: Trigger purchaseUpdated callback when iap purchased #165.

2.1.0 #

2.0.5 #

  • Hotfix #221
  • Use AAC-LC format instead of MPEG-4 #209

2.0.4 #

  • OGG/OPUS support on iOS #199

2.0.3 #

  • Resolve #194
    • stopReocorder resolve path.
  • Resolve #198
    • Improve static handler in android.

2.0.1 #

  • Add compatibility for android sdk 19.
  • Add androidx compatibility.
  • Resolve #193
    • Restore default startRecorder

1.9.0 #

  • Fix issue #175
    • add functions . isEncoderSupported(t_CODEC codec); . isDecoderSupported(t_CODEC codec);
    • add property 'audioState'
    • check if codec is really supported before doing 'startRecorder'
    • modify the example app : disable buttons when the button is not compatible with the current state
    • in the example, add sound assets encoded with the various encoder
    • modify the example to play from assets
    • modify the example to allow selection of various codec

1.7.0 #

  • startPlayerFromBuffer, to play from a buffer #170

1.6.0 #

  • Set android default encoding option to AAC.
  • Fix android default poor sound.

1.5.2 #

  • Postfix GetDirectoryType to avoid conflicts #147

1.5.1 #

  • Set android recorder encoder default value to AndroidEncoder.DEFAULT.

1.5.0 #

  • Use NSCachesDirectory instead of NSTemporaryDirectory #141

1.4.8 #

1.4.7 #

  • Resolve few issues on ios record path.
  • Resolve issue playing status so player can resume.
  • Resolve #134
  • Resolve #135

1.4.4 #

  • Stopped recording generating infinite db values #131

1.4.3 #

  • Improved db calcs #123

1.4.2 #

  • Fixed 'mediaplayer went away with unhandled events' bug #104

1.4.1 #

  • Fixed 'mediaplayer went away with unhandled events' bug #83

1.4.0 #

  • AndroidX compatibility improved #68
  • iOS: Fixes for seekToPlayer #72
  • iOS: Setup configuration for using bluetooth microphone recording input #73

1.3.6 #

  • Android: Adds a single threaded command scheduler for all recording related commands.
  • Switch source & target compability to Java 8
  • Bump gradle plugin version dependencies

1.3.+ #

  • Support db/meter #41
  • Show wrong recorder timer text #47
  • Add ability to specify Android & iOS encoder #49
  • Adjust db range and fix nullable check in ios #59
  • Android: Recording operations on a separate command queue #66
  • Android: Remove reference to non-AndroidX classes which improves compatibility

1.2.+ #

  • Fixed sound distorting when playing recorded audio again. Issue #14.
  • Fixed seekToPlayer for android. Issue #10.
  • Expose recorder sampleRate and numChannel.
  • Do not append tmp when filePath provided in ios.
  • Resolve regression issue in 1.2.3 which caused in 1.2.2.
  • Reduce the size of audio file in 1.2.4. Related #26.
  • Fixed recording issue in android in 1.2.5.
  • Changed seekToPlayer to place exact secs instead adding it.
  • Fix file URI for recording and playing in iOS.

1.1.+ #

  • Released 1.1.0 with beautiful logo from mansa.
  • Improved readme.
  • Resolve #7.
  • Fixed missing break in switch statement.

1.0.9 #

  • Reimport intl which is needed to format date in Dart.

1.0.8 #

  • Implemented setVolume method.
  • Specific error messages given in android.
  • Manage ios player thread when audio is not loaded.

1.0.7 #

  • Safer handling of progressUpdate in ios when audio is invalid.

1.0.6 #

  • Fixed bug in platform specific code.

1.0.5 #

  • Fixed pug in seekToPlayer in ios.

1.0.3 #

  • Added license.

1.0.0 #

  • Released preview version for audio recorder and player.

example/lib/main.dart

/*
 * This file is part of Flauto.
 *
 *   Flauto is free software: you can redistribute it and/or modify
 *   it under the terms of the Lesser GNU General Public License
 *   version 3 (LGPL3) as published by the Free Software Foundation.
 *
 *   Flauto is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the Lesser GNU General Public License
 *   along with Flauto.  If not, see <https://www.gnu.org/licenses/>.
 */

import 'dart:async';
import 'dart:io';
import 'dart:typed_data' show Uint8List;

import 'package:flutter/material.dart';
import 'package:flauto/flutter_sound.dart';
import 'package:path_provider/path_provider.dart' show getTemporaryDirectory;
import 'package:flutter/services.dart' show rootBundle;
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart' show DateFormat;
import 'package:flauto/flauto.dart';

enum t_MEDIA
{
        FILE,
        BUFFER,
        ASSET,
        STREAM,
        REMOTE_EXAMPLE_FILE,
}

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

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

class _MyAppState extends State<MyApp>
{
        bool _isRecording = false;
        List<String> _path = [null, null, null, null, null, null, null];
        StreamSubscription _recorderSubscription;
        StreamSubscription _dbPeakSubscription;
        StreamSubscription _playerSubscription;
        StreamSubscription _playbackStateSubscription;
        static FlutterSound flutterSoundModule;

        String _recorderTxt = '00:00:00';
        String _playerTxt = '00:00:00';
        double _dbLevel;

        double sliderCurrentPosition = 0.0;
        double maxDuration = 1.0;
        t_MEDIA _media = t_MEDIA.FILE;
        t_CODEC _codec = t_CODEC.CODEC_AAC;

        bool _encoderSupported = true; // Optimist
        bool _decoderSupported = true; // Optimist

        // Whether the media player has been initialized and the UI controls can
        // be displayed.
        bool _canDisplayPlayerControls = false;

        // Whether the user wants to use the audio player features
        bool _isAudioPlayer = false;
        bool _duckOthers = false;

        void _initializeExample( FlutterSound module )
        async {
                flutterSoundModule = module;
                flutterSoundModule.initializeMediaPlayer( );
                flutterSoundModule.setSubscriptionDuration( 0.01 );
                flutterSoundModule.setDbPeakLevelUpdate( 0.8 );
                flutterSoundModule.setDbLevelEnabled( true );
                initializeDateFormatting( );
                setCodec( _codec );
                setDuck( );
        }

        @override
        void initState( )
        {
                super.initState( );
                _initializeExample( FlutterSound( ) );
        }

        void cancelRecorderSubscriptions( )
        {
                if (_recorderSubscription != null)
                {
                        _recorderSubscription.cancel( );
                        _recorderSubscription = null;
                }
                if (_dbPeakSubscription != null)
                {
                        _dbPeakSubscription.cancel( );
                        _dbPeakSubscription = null;
                }
        }

        void cancelPlayerSubscriptions( )
        {
                if (_playerSubscription != null)
                {
                        _playerSubscription.cancel( );
                        _playerSubscription = null;
                }

                if (_playbackStateSubscription != null)
                {
                        _playbackStateSubscription.cancel( );
                        _playbackStateSubscription = null;
                }
        }

        @override
        void dispose( )
        {
                super.dispose( );
                cancelPlayerSubscriptions( );
                cancelRecorderSubscriptions( );
                releasePlayer( );
        }

        Future<void> setDuck( )
        async {
                if (_duckOthers)
                {
                        if (Platform.isIOS)
                                await flutterSoundModule.iosSetCategory( t_IOS_SESSION_CATEGORY.PLAY_AND_RECORD, t_IOS_SESSION_MODE.DEFAULT, IOS_DUCK_OTHERS | IOS_DEFAULT_TO_SPEAKER );
                        else if (Platform.isAndroid) await flutterSoundModule.androidAudioFocusRequest( ANDROID_AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK );
                } else
                {
                        if (Platform.isIOS)
                                await flutterSoundModule.iosSetCategory( t_IOS_SESSION_CATEGORY.PLAY_AND_RECORD, t_IOS_SESSION_MODE.DEFAULT, IOS_DEFAULT_TO_SPEAKER );
                        else if (Platform.isAndroid) await flutterSoundModule.androidAudioFocusRequest( ANDROID_AUDIOFOCUS_GAIN );
                }
        }

        Future<void> releasePlayer( )
        async {
                try
                {
                        await flutterSoundModule.releaseMediaPlayer( );
                        print( 'media player released successfully' );
                        setState( ( )
                                  {
                                          _canDisplayPlayerControls = false;
                                  } );
                }
                catch (e)
                {
                        print( 'media player released unsuccessful' );
                        print( e );
                }
        }

        static const List<String> paths = [
                'sound.aac', // DEFAULT
                'sound.aac', // CODEC_AAC
                'sound.opus', // CODEC_OPUS
                'sound.caf', // CODEC_CAF_OPUS
                'sound.mp3', // CODEC_MP3
                'sound.ogg', // CODEC_VORBIS
                'sound.wav', // CODEC_PCM
        ];

        void startRecorder( )
        async {
                try
                {
                        // String path = await flutterSoundModule.startRecorder
                        // (
                        //   paths[_codec.index],
                        //   codec: _codec,
                        //   sampleRate: 16000,
                        //   bitRate: 16000,
                        //   numChannels: 1,
                        //   androidAudioSource: AndroidAudioSource.MIC,
                        // );
                        Directory tempDir = await getTemporaryDirectory( );

                        String path = await flutterSoundModule.startRecorder(
                                uri: '${tempDir.path}/${paths[_codec.index]}',
                                codec: _codec,
                                );
                        print( 'startRecorder: $path' );

                        _recorderSubscription = flutterSoundModule.onRecorderStateChanged.listen( ( e )
                                                                                                  {
                                                                                                          if (e.currentPosition != null)
                                                                                                          {
                                                                                                                  DateTime date = new DateTime.fromMillisecondsSinceEpoch( e.currentPosition.toInt( ), isUtc: true );
                                                                                                                  String txt = DateFormat( 'mm:ss:SS', 'en_GB' ).format( date );

                                                                                                                  this.setState( ( )
                                                                                                                                 {
                                                                                                                                         this._recorderTxt = txt.substring( 0, 8 );
                                                                                                                                 } );
                                                                                                          }
                                                                                                  } );
                        _dbPeakSubscription = flutterSoundModule.onRecorderDbPeakChanged.listen( ( value )
                                                                                                 {
                                                                                                         print( "got update -> $value" );
                                                                                                         setState( ( )
                                                                                                                   {
                                                                                                                           this._dbLevel = value;
                                                                                                                   } );
                                                                                                 } );

                        this.setState( ( )
                                       {
                                               this._isRecording = true;
                                               this._path[_codec.index] = path;
                                       } );
                }
                catch (err)
                {
                        print( 'startRecorder error: $err' );
                        setState( ( )
                                  {
                                          stopRecorder( );
                                          this._isRecording = false;
                                          if (_recorderSubscription != null)
                                          {
                                                  _recorderSubscription.cancel( );
                                                  _recorderSubscription = null;
                                          }
                                          if (_dbPeakSubscription != null)
                                          {
                                                  _dbPeakSubscription.cancel( );
                                                  _dbPeakSubscription = null;
                                          }
                                  } );
                }
        }

        void stopRecorder( )
        async {
                try
                {
                        String result = await flutterSoundModule.stopRecorder( );
                        print( 'stopRecorder: $result' );
                        cancelRecorderSubscriptions( );
                }
                catch (err)
                {
                        print( 'stopRecorder error: $err' );
                }
                this.setState( ( )
                               {
                                       this._isRecording = false;
                               } );
        }

        Future<bool> fileExists( String path )
        async {
                return await File( path ).exists( );
        }

        // In this simple example, we just load a file in memory.This is stupid but just for demonstration  of startPlayerFromBuffer()
        Future<Uint8List> makeBuffer( String path )
        async {
                try
                {
                        if (!await fileExists( path )) return null;
                        File file = File( path );
                        file.openRead( );
                        var contents = await file.readAsBytes( );
                        print( 'The file is ${contents.length} bytes long.' );
                        return contents;
                }
                catch (e)
                {
                        print( e );
                        return null;
                }
        }

        List<String> assetSample = [
                'assets/samples/sample.aac',
                'assets/samples/sample.aac',
                'assets/samples/sample.opus',
                'assets/samples/sample.caf',
                'assets/samples/sample.mp3',
                'assets/samples/sample.ogg',
                'assets/samples/sample.wav',
        ];

        void _addListeners( )
        {
                cancelPlayerSubscriptions( );
                _playerSubscription = flutterSoundModule.onPlayerStateChanged.listen( ( e )
                                                                                      {
                                                                                              if (e != null)
                                                                                              {
                                                                                                      sliderCurrentPosition = e.currentPosition;
                                                                                                      maxDuration = e.duration;

                                                                                                      DateTime date = new DateTime.fromMillisecondsSinceEpoch( e.currentPosition.toInt( ), isUtc: true );
                                                                                                      String txt = DateFormat( 'mm:ss:SS', 'en_GB' ).format( date );
                                                                                                      this.setState( ( )
                                                                                                                     {
                                                                                                                             //this._isPlaying = true;
                                                                                                                             this._playerTxt = txt.substring( 0, 8 );
                                                                                                                     } );
                                                                                              }
                                                                                      } );
        }

        Future<void> startPlayer( )
        async {
                try
                {
                        final exampleAudioFilePath = "https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3";
                        final albumArtPath = "https://file-examples.com/wp-content/uploads/2017/10/file_example_PNG_500kB.png";
                        //final albumArtPath =
                        //"https://file-examples.com/wp-content/uploads/2017/10/file_example_PNG_500kB.png";

                        String path;
                        Uint8List dataBuffer;
                        String audioFilePath;
                        if (_media == t_MEDIA.ASSET)
                        {
                                dataBuffer = (await rootBundle.load( assetSample[_codec.index] )).buffer.asUint8List( );
                        } else if (_media == t_MEDIA.FILE)
                        {
                                // Do we want to play from buffer or from file ?
                                if (await fileExists( _path[_codec.index] )) audioFilePath = this._path[_codec.index];
                        } else if (_media == t_MEDIA.BUFFER)
                        {
                                // Do we want to play from buffer or from file ?
                                if (await fileExists( _path[_codec.index] ))
                                {
                                        dataBuffer = await makeBuffer( this._path[_codec.index] );
                                        if (dataBuffer == null)
                                        {
                                                throw Exception( 'Unable to create the buffer' );
                                        }
                                }
                        } else if (_media == t_MEDIA.REMOTE_EXAMPLE_FILE)
                        {
                                // We have to play an example audio file loaded via a URL
                                audioFilePath = exampleAudioFilePath;
                        }

                        // Check whether the user wants to use the audio player features
                        if (_isAudioPlayer)
                        {
                                String albumArtUrl;
                                String albumArtAsset;
                                if (_media == t_MEDIA.REMOTE_EXAMPLE_FILE)
                                        albumArtUrl = albumArtPath;
                                else
                                {
                                        if (Platform.isIOS)
                                        {
                                                albumArtAsset = 'AppIcon';
                                        } else if (Platform.isAndroid)
                                        {
                                                albumArtAsset = 'AppIcon.png';
                                        }
                                }

                                final track = Track(
                                        trackPath: audioFilePath,
                                        dataBuffer: dataBuffer,
                                        codec: _codec,
                                        trackTitle: "This is a record",
                                        trackAuthor: "from flutter_sound",
                                        albumArtUrl: albumArtUrl,
                                        albumArtAsset: albumArtAsset,
                                        );


                                Flauto flauto = flutterSoundModule;
                                path = await flauto.startPlayerFromTrack(
                                        track,
                                        /*canSkipForward:true, canSkipBackward:true,*/
                                        whenFinished: ( )
                                        {
                                                print( 'I hope you enjoyed listening to this song' );
                                        },
                                        onSkipBackward: ( )
                                        {
                                                print( 'Skip backward' );
                                                stopPlayer( );
                                                startPlayer( );
                                        },
                                        onSkipForward: ( )
                                        {
                                                print( 'Skip forward' );
                                                stopPlayer( );
                                                startPlayer( );
                                        },
                                        );
                        } else
                        {
                                if (audioFilePath != null)
                                {
                                        path = await flutterSoundModule.startPlayer( audioFilePath, codec: _codec, whenFinished: ( )
                                        {
                                                print( 'Play finished' );
                                                setState( ( )
                                                          {} );
                                        } );
                                } else if (dataBuffer != null)
                                {
                                        path = await flutterSoundModule.startPlayerFromBuffer( dataBuffer, codec: _codec, whenFinished: ( )
                                        {
                                                print( 'Play finished' );
                                                setState( ( )
                                                          {} );
                                        } );
                                }

                                if (path == null)
                                {
                                        print( 'Error starting player' );
                                        return;
                                }
                        }
                        _addListeners( );

                        print( 'startPlayer: $path' );
                        // await flutterSoundModule.setVolume(1.0);
                }
                catch (err)
                {
                        print( 'error: $err' );
                }
                setState( ( )
                          {} );
        }

        Future<void> stopPlayer( )
        async {
                try
                {
                        String result = await flutterSoundModule.stopPlayer( );
                        print( 'stopPlayer: $result' );
                        if (_playerSubscription != null)
                        {
                                _playerSubscription.cancel( );
                                _playerSubscription = null;
                        }
                        sliderCurrentPosition = 0.0;
                }
                catch (err)
                {
                        print( 'error: $err' );
                }
                this.setState( ( )
                               {
                                       //this._isPlaying = false;
                               } );
        }

        pauseResumePlayer( )
        {
                if (flutterSoundModule.audioState == t_AUDIO_STATE.IS_PLAYING)
                {
                        flutterSoundModule.pausePlayer( );
                } else
                {
                        flutterSoundModule.resumePlayer( );
                }
        }

        void seekToPlayer( int milliSecs )
        async {
                String result = await flutterSoundModule.seekToPlayer( milliSecs );
                print( 'seekToPlayer: $result' );
        }

        Widget makeDropdowns( BuildContext context )
        {
                final mediaDropdown = Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                                Padding(
                                        padding: const EdgeInsets.only( right: 16.0 ),
                                        child: Text( 'Media:' ),
                                        ),
                                DropdownButton<t_MEDIA>(
                                        value: _media,
                                        onChanged: ( newMedia )
                                        {
                                                setState( ( )
                                                          {
                                                                  if (newMedia == t_MEDIA.REMOTE_EXAMPLE_FILE) _codec = t_CODEC.CODEC_MP3; // Actually this is the only example we use in this example
                                                                  _media = newMedia;
                                                          } );
                                        },
                                        items: <DropdownMenuItem<t_MEDIA>>[
                                                DropdownMenuItem<t_MEDIA>(
                                                        value: t_MEDIA.FILE,
                                                        child: Text( 'File' ),
                                                        ),
                                                DropdownMenuItem<t_MEDIA>(
                                                        value: t_MEDIA.BUFFER,
                                                        child: Text( 'Buffer' ),
                                                        ),
                                                DropdownMenuItem<t_MEDIA>(
                                                        value: t_MEDIA.ASSET,
                                                        child: Text( 'Asset' ),
                                                        ),
                                                DropdownMenuItem<t_MEDIA>(
                                                        value: t_MEDIA.REMOTE_EXAMPLE_FILE,
                                                        child: Text( 'Remote Example File' ),
                                                        ),
                                        ],
                                        ),
                        ],
                        );

                final codecDropdown = Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                                Padding(
                                        padding: const EdgeInsets.only( right: 16.0 ),
                                        child: Text( 'Codec:' ),
                                        ),
                                DropdownButton<t_CODEC>(
                                        value: _codec,
                                        onChanged: ( newCodec )
                                        {
                                                setCodec( newCodec );
                                                setState( ( )
                                                          {
                                                                  _codec = newCodec;
                                                          } );
                                        },
                                        items: <DropdownMenuItem<t_CODEC>>[
                                                DropdownMenuItem<t_CODEC>(
                                                        value: t_CODEC.CODEC_AAC,
                                                        child: Text( 'AAC' ),
                                                        ),
                                                DropdownMenuItem<t_CODEC>(
                                                        value: t_CODEC.CODEC_OPUS,
                                                        child: Text( 'OGG/Opus' ),
                                                        ),
                                                DropdownMenuItem<t_CODEC>(
                                                        value: t_CODEC.CODEC_CAF_OPUS,
                                                        child: Text( 'CAF/Opus' ),
                                                        ),
                                                DropdownMenuItem<t_CODEC>(
                                                        value: t_CODEC.CODEC_MP3,
                                                        child: Text( 'MP3' ),
                                                        ),
                                                DropdownMenuItem<t_CODEC>(
                                                        value: t_CODEC.CODEC_VORBIS,
                                                        child: Text( 'OGG/Vorbis' ),
                                                        ),
                                                DropdownMenuItem<t_CODEC>(
                                                        value: t_CODEC.CODEC_PCM,
                                                        child: Text( 'PCM' ),
                                                        ),
                                        ],
                                        ),
                        ],
                        );

                return Padding(
                        padding: const EdgeInsets.all( 8.0 ),
                        child: Column(
                                mainAxisAlignment: MainAxisAlignment.start,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: <Widget>[
                                        Padding(
                                                padding: const EdgeInsets.only( bottom: 16.0 ),
                                                child: mediaDropdown,
                                                ),
                                        codecDropdown,
                                ],
                                ),
                        );
        }

        onPauseResumePlayerPressed( )
        {
                switch (flutterSoundModule.audioState)
                {
                        case t_AUDIO_STATE.IS_PAUSED:
                                return pauseResumePlayer;
                                break;
                        case t_AUDIO_STATE.IS_PLAYING:
                                return pauseResumePlayer;
                                break;
                        case t_AUDIO_STATE.IS_STOPPED:
                                return null;
                                break;
                        case t_AUDIO_STATE.IS_RECORDING:
                                return null;
                                break;
                }
        }

        onStopPlayerPressed( )
        {
                return flutterSoundModule.audioState == t_AUDIO_STATE.IS_PLAYING || flutterSoundModule.audioState == t_AUDIO_STATE.IS_PAUSED ? stopPlayer : null;
        }

        onStartPlayerPressed( )
        {
                if (_media == t_MEDIA.FILE || _media == t_MEDIA.BUFFER) // A file must be already recorded to play it
                {
                        if (_path[_codec.index] == null) return null;
                }
                if (_media == t_MEDIA.REMOTE_EXAMPLE_FILE && _codec != t_CODEC.CODEC_MP3) // in this example we use just a remote mp3 file
                        return null;

                // Disable the button if the selected codec is not supported
                if (!_decoderSupported) return null;
                return flutterSoundModule.audioState == t_AUDIO_STATE.IS_STOPPED ? startPlayer : null;
        }

        void startStopRecorder( )
        {
                if (flutterSoundModule.audioState == t_AUDIO_STATE.IS_RECORDING)
                        stopRecorder( );
                else
                        startRecorder( );
        }

        onStartRecorderPressed( )
        {
                if (_media == t_MEDIA.ASSET || _media == t_MEDIA.BUFFER || _media == t_MEDIA.REMOTE_EXAMPLE_FILE) return null;
                // Disable the button if the selected codec is not supported
                if (!_encoderSupported) return null;
                if (flutterSoundModule.audioState == t_AUDIO_STATE.IS_PAUSED || flutterSoundModule.audioState == t_AUDIO_STATE.IS_PLAYING) return null;
                return startStopRecorder;
        }

        AssetImage recorderAssetImage( )
        {
                if (onStartRecorderPressed( ) == null) return AssetImage( 'res/icons/ic_mic_disabled.png' );
                return flutterSoundModule.audioState == t_AUDIO_STATE.IS_STOPPED ? AssetImage( 'res/icons/ic_mic.png' ) : AssetImage( 'res/icons/ic_stop.png' );
        }

        setCodec( t_CODEC codec )
        async {
                _encoderSupported = await flutterSoundModule.isEncoderSupported( codec );
                _decoderSupported = await flutterSoundModule.isDecoderSupported( codec );

                setState( ( )
                          {
                                  _codec = codec;
                          } );
        }

        audioPlayerSwitchChanged( )
        {
                if (flutterSoundModule.audioState != t_AUDIO_STATE.IS_STOPPED) return null;
                return (( newVal )
                async {
                        try
                        {
                                if (flutterSoundModule != null) flutterSoundModule.releaseMediaPlayer( );

                                _isAudioPlayer = newVal;
                                if (!newVal)
                                {
                                        _initializeExample( FlutterSound( ) );
                                } else
                                {
                                        _initializeExample( Flauto( ) );
                                }
                                setState( ( )
                                          {} );
                        }
                        catch (err)
                        {
                                print( err );
                        }
                });
        }

        duckOthersSwitchChanged( )
        {
                return (( newVal )
                async {
                        _duckOthers = newVal;

                        try
                        {
                                setDuck( );
                                setState( ( )
                                          {} );
                        }
                        catch (err)
                        {
                                print( err );
                        }
                });
        }

        @override
        Widget build( BuildContext context )
        {
                final recorderProgressIndicator = _isRecording
                                                  ? LinearProgressIndicator(
                        value: 100.0 / 160.0 * (this._dbLevel ?? 1) / 100,
                        valueColor: AlwaysStoppedAnimation<Color>( Colors.green ),
                        backgroundColor: Colors.red,
                        )
                                                  : Container( );
                final playerControls = ((!_canDisplayPlayerControls) && _isAudioPlayer)
                                       ? Container( child: Container( child: CircularProgressIndicator( ) ) )
                                       : Row(
                        children: <Widget>[
                                Container(
                                        width: 56.0,
                                        height: 56.0,
                                        child: ClipOval(
                                                child: FlatButton(
                                                        onPressed: onStartPlayerPressed( ),
                                                        padding: EdgeInsets.all( 8.0 ),
                                                        child: Image(
                                                                image: AssetImage( onStartPlayerPressed( ) != null ? 'res/icons/ic_play.png' : 'res/icons/ic_play_disabled.png' ),
                                                                ),
                                                        ),
                                                ),
                                        ),
                                Container(
                                        width: 56.0,
                                        height: 56.0,
                                        child: ClipOval(
                                                child: FlatButton(
                                                        onPressed: onPauseResumePlayerPressed( ),
                                                        padding: EdgeInsets.all( 8.0 ),
                                                        child: Image(
                                                                width: 36.0,
                                                                height: 36.0,
                                                                image: AssetImage( onPauseResumePlayerPressed( ) != null ? 'res/icons/ic_pause.png' : 'res/icons/ic_pause_disabled.png' ),
                                                                ),
                                                        ),
                                                ),
                                        ),
                                Container(
                                        width: 56.0,
                                        height: 56.0,
                                        child: ClipOval(
                                                child: FlatButton(
                                                        onPressed: onStopPlayerPressed( ),
                                                        padding: EdgeInsets.all( 8.0 ),
                                                        child: Image(
                                                                width: 28.0,
                                                                height: 28.0,
                                                                image: AssetImage( onStopPlayerPressed( ) != null ? 'res/icons/ic_stop.png' : 'res/icons/ic_stop_disabled.png' ),
                                                                ),
                                                        ),
                                                ),
                                        ),
                        ],
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        );
                final playerSlider = Container(
                            height: 56.0,
                            child: Slider(
                                        value: sliderCurrentPosition,
                                        min: 0.0,
                                        max: maxDuration,
                                        onChanged: ( double value )
                                        async {
                                                await flutterSoundModule.seekToPlayer( value.toInt( ) );
                                        },
                                        divisions: maxDuration == 0.0 ? 1 : maxDuration.toInt( ) ) );

                final dropdowns = makeDropdowns( context );
                final trackSwitch = Padding(
                        padding: const EdgeInsets.all( 8.0 ),
                        child: Row(
                                children: <Widget>[
                                        Padding(
                                                padding: const EdgeInsets.only( right: 4 ),
                                                child: Text( '"Flauto":' ),
                                                ),
                                        Switch(
                                                value: _isAudioPlayer,
                                                onChanged: audioPlayerSwitchChanged( ),
                                                ),
                                        Padding(
                                                padding: const EdgeInsets.only( right: 4.0 ),
                                                child: Text( 'Duck Others:' ),
                                                ),
                                        Switch(
                                                value: _duckOthers,
                                                onChanged: duckOthersSwitchChanged( ),
                                                ),
                                ],
                                ),
                        );

                Widget recorderSection = Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
                        Container(
                                margin: EdgeInsets.only( top: 12.0, bottom: 16.0 ),
                                child: Text(
                                        this._recorderTxt,
                                        style: TextStyle(
                                                fontSize: 35.0,
                                                color: Colors.black,
                                                ),
                                        ),
                                ),
                        _isRecording ? LinearProgressIndicator( value: 100.0 / 160.0 * (this._dbLevel ?? 1) / 100, valueColor: AlwaysStoppedAnimation<Color>( Colors.green ), backgroundColor: Colors.red ) : Container( ),
                        Row(
                                children: <Widget>[
                                        Container(
                                                width: 56.0,
                                                height: 50.0,
                                                child: ClipOval(
                                                        child: FlatButton(
                                                                onPressed: onStartRecorderPressed( ),
                                                                padding: EdgeInsets.all( 8.0 ),
                                                                child: Image(
                                                                        image: recorderAssetImage( ),
                                                                        ),
                                                                ),
                                                        ),
                                                ),
                                ],
                                mainAxisAlignment: MainAxisAlignment.center,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                ),
                ] );

                Widget playerSection = Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                                Container(
                                        margin: EdgeInsets.only( top: 12.0, bottom: 16.0 ),
                                        child: Text(
                                                this._playerTxt,
                                                style: TextStyle(
                                                        fontSize: 35.0,
                                                        color: Colors.black,
                                                        ),
                                                ),
                                        ),
                                Row(
                                        children: <Widget>[
                                                Container(
                                                        width: 56.0,
                                                        height: 50.0,
                                                        child: ClipOval(
                                                                child: FlatButton(
                                                                        onPressed: onStartPlayerPressed( ),
                                                                        disabledColor: Colors.white,
                                                                        padding: EdgeInsets.all( 8.0 ),
                                                                        child: Image(
                                                                                image: AssetImage( onStartPlayerPressed( ) != null ? 'res/icons/ic_play.png' : 'res/icons/ic_play_disabled.png' ),
                                                                                ),
                                                                        ),
                                                                ),
                                                        ),
                                                Container(
                                                        width: 56.0,
                                                        height: 50.0,
                                                        child: ClipOval(
                                                                child: FlatButton(
                                                                        onPressed: onPauseResumePlayerPressed( ),
                                                                        disabledColor: Colors.white,
                                                                        padding: EdgeInsets.all( 8.0 ),
                                                                        child: Image(
                                                                                width: 36.0,
                                                                                height: 36.0,
                                                                                image: AssetImage( onPauseResumePlayerPressed( ) != null ? 'res/icons/ic_pause.png' : 'res/icons/ic_pause_disabled.png' ),
                                                                                ),
                                                                        ),
                                                                ),
                                                        ),
                                                Container(
                                                        width: 56.0,
                                                        height: 50.0,
                                                        child: ClipOval(
                                                                child: FlatButton(
                                                                        onPressed: onStopPlayerPressed( ),
                                                                        disabledColor: Colors.white,
                                                                        padding: EdgeInsets.all( 8.0 ),
                                                                        child: Image(
                                                                                width: 28.0,
                                                                                height: 28.0,
                                                                                image: AssetImage( onStopPlayerPressed( ) != null ? 'res/icons/ic_stop.png' : 'res/icons/ic_stop_disabled.png' ),
                                                                                ),
                                                                        ),
                                                                ),
                                                        ),
                                        ],
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        crossAxisAlignment: CrossAxisAlignment.center,
                                        ),
                                Container(
                                            height: 30.0,
                                            child: Slider(
                                                        value: sliderCurrentPosition,
                                                        min: 0.0,
                                                        max: maxDuration,
                                                        onChanged: ( double value )
                                                        async {
                                                                await flutterSoundModule.seekToPlayer( value.toInt( ) );
                                                        },
                                                        divisions: maxDuration == 0.0 ? 1 : maxDuration.toInt( ) ) ),
                        ],
                        );

                return MaterialApp(
                        home: Scaffold(
                                appBar: AppBar(
                                        title: const Text( 'Flutter Sound' ),
                                        ),
                                body: ListView(
                                        children: <Widget>[
                                                recorderSection,
                                                playerSection,
                                                dropdowns,
                                                trackSwitch,
                                        ],
                                        ),
                                ),
                        );
        }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flauto: ^3.0.1+1

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

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because of import path [package:flauto/flauto.dart, package:path_provider/path_provider.dart, package:path_provider_linux/path_provider_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform ios

Because of import path [package:flauto/flauto.dart, package:path_provider/path_provider.dart, package:path_provider_linux/path_provider_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform linux

Because of import path [package:flauto/flauto.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:flauto/flauto.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:flauto/flauto.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:flauto/flauto.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [flauto] that is in a package requiring null.

Health suggestions

Fix lib/flauto.dart. (-4.41 points)

Analysis of lib/flauto.dart reported 9 hints, including:

line 72 col 5: Don't explicitly initialize variables to null.

line 73 col 5: Don't explicitly initialize variables to null.

line 103 col 19: 'await' applied to 'File', which is not a 'Future'.

line 114 col 20: 'await' applied to 'File', which is not a 'Future'.

line 128 col 40: Avoid using braces in interpolation when not needed.

Fix lib/flutter_sound.dart. (-1.99 points)

Analysis of lib/flutter_sound.dart reported 4 hints:

line 126 col 14: Name types using UpperCamelCase.

line 127 col 14: Name types using UpperCamelCase.

line 128 col 14: Name types using UpperCamelCase.

line 129 col 14: Name types using UpperCamelCase.

Format lib/android_encoder.dart.

Run flutter format to format lib/android_encoder.dart.

Format lib/ios_quality.dart.

Run flutter format to format lib/ios_quality.dart.

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 (permission_handler).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
path >=1.0.0 <2.0.0 1.7.0
path_provider >=1.0.0 <2.0.0 1.6.11
permission_handler ^4.4.0 4.4.0+hotfix.4 5.0.1+1
Transitive dependencies
collection 1.14.12 1.14.13
file 5.2.1
intl 0.16.1
meta 1.1.8
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
permission_handler_platform_interface 1.0.0 2.0.1
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
xdg_directories 0.1.0