pcm16khz_audio_recorder 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 0

pcm16khz_audio_recorder #

A new flutter plugin project.

This is fork of pcm16khz_audio_recorder by dcanada, please refer https://github.com/dcanada/pcm16khz_audio_recorder for usgae instructions

(why this plugin? : dcanada seems inactive and I had urgent need)

Getting Started #

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

For help on editing plugin code, view the documentation.

0.0.1 #

  • TODO: Describe initial release.


import 'package:flutter/material.dart';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'dart:math';
import 'package:pcm16khz_audio_recorder/pcm16khz_audio_recorder.dart';

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

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

class _MyAppState extends State<MyApp> {

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin audio recorder'),
        body: new AppBody(),

class AppBody extends StatefulWidget{

  State<StatefulWidget> createState() => new AppBodyState();

class AppBodyState extends State<AppBody>{
  Recording _recording = new Recording();
  bool _isRecording = false;
  Random random = new Random();
  TextEditingController _controller = new TextEditingController();

  Widget build(BuildContext context) {
    return new Center(
      child: new Padding(
        padding: new EdgeInsets.all(8.0),
        child: new Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              new FlatButton(onPressed: _isRecording ? null : _start, child: new Text("Start"), color: Colors.green,),
              new FlatButton(onPressed: _isRecording ? _stop : null, child: new Text("Stop"), color: Colors.red,),
              new TextField(controller: _controller, decoration: new InputDecoration(hintText: 'Enter a custom path',),),
              new Text("File path of the record: ${_recording.path}"),
              new Text("Format: ${_recording.audioOutputFormat}"),
              new Text("Extension : ${_recording.extension}"),
              new Text("Audio recording duration : ${_recording.duration.toString()}" )

  _start() async {
    try {
      if (await Pcm16khzAudioRecorder.hasPermissions) {
        if (_controller.text != null && _controller.text != "") {
          String path = _controller.text;
          if (!_controller.text.contains('/')) {
            Directory appDocDirectory = await getApplicationDocumentsDirectory();
            path = appDocDirectory.path + '/' + _controller.text;
          print("Start recording: $path");
          await Pcm16khzAudioRecorder.start(path: path, audioOutputFormat: AudioOutputFormat.AAC);
        } else {
          await Pcm16khzAudioRecorder.start();
        bool isRecording = await Pcm16khzAudioRecorder.isRecording;
        setState(() {
          _recording = new Recording(duration: new Duration(), path: "");
          _isRecording = isRecording;
      } else {
        Scaffold.of(context).showSnackBar(new SnackBar(content: new Text("You must accept permissions")));
    } catch (e){

  _stop() async {
    var recording = await Pcm16khzAudioRecorder.stop();
    print("Stop recording: ${recording.path}");
    bool isRecording = await Pcm16khzAudioRecorder.isRecording;
    File file = await new File(recording.path);
    print("  File length: ${await file.length()}");
    setState(() {
      _recording = recording;
      _isRecording = isRecording;
    _controller.text = recording.path;

Use this package as a library

1. Depend on it

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

  pcm16khz_audio_recorder: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:pcm16khz_audio_recorder/pcm16khz_audio_recorder.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 Apr 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running flutter pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.7.0.
 Because pcm16khz_audio_recorder requires SDK version >=1.19.0 <=2.1.0, version solving failed.

Health suggestions

Format lib/pcm16khz_audio_recorder.dart.

Run flutter format to format lib/pcm16khz_audio_recorder.dart.

Maintenance issues and suggestions

Support future stable Dart 2 SDKs in pubspec.yaml. (-20 points)

The SDK constraint in pubspec.yaml doesn't allow future stable Dart 2.x SDK releases.

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Package is getting outdated. (-20.27 points)

The package was last published 62 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <=2.1.0