liuyuqi-dellpc 2 years ago
parent
commit
de54b98654

+ 4 - 8
README.md

@@ -1,16 +1,12 @@
 # flutter_audio_recorder
 
-A new Flutter application.
+flutter 录音机App
 
 ## Getting Started
 
-This project is a starting point for a Flutter application.
 
-A few resources to get you started if this is your first Flutter project:
+  注意:
+
+permission_handler: ^8.3.0   android 编译版本需要设置为31
 
-- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
-- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
 
-For help getting started with Flutter, view our
-[online documentation](https://flutter.dev/docs), which offers tutorials,
-samples, guidance on mobile development, and a full API reference.

+ 2 - 2
android/app/build.gradle

@@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
 
 android {
-    compileSdkVersion 30
+    compileSdkVersion 31
 
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
@@ -36,7 +36,7 @@ android {
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
         applicationId "me.yoqi.flutter.flutter_audio_recorder"
         minSdkVersion 16
-        targetSdkVersion 30
+        targetSdkVersion 31
         versionCode flutterVersionCode.toInteger()
         versionName flutterVersionName
     }

+ 4 - 0
android/app/src/debug/AndroidManifest.xml

@@ -4,4 +4,8 @@
          to allow setting breakpoints, to provide hot reload, etc.
     -->
     <uses-permission android:name="android.permission.INTERNET"/>
+    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+
 </manifest>

+ 17 - 12
android/app/src/main/AndroidManifest.xml

@@ -1,35 +1,40 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="me.yoqi.flutter.flutter_audio_recorder">
-   <application
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+
+    <application
+        android:icon="@drawable/ic_launcher"
         android:label="flutter_audio_recorder"
-        android:icon="@mipmap/ic_launcher">
+        android:requestLegacyExternalStorage="true">
         <activity
             android:name=".MainActivity"
-            android:launchMode="singleTop"
-            android:theme="@style/LaunchTheme"
             android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
             android:hardwareAccelerated="true"
+            android:launchMode="singleTop"
+            android:theme="@style/LaunchTheme"
             android:windowSoftInputMode="adjustResize">
             <!-- Specifies an Android theme to apply to this Activity as soon as
                  the Android process has started. This theme is visible to the user
                  while the Flutter UI initializes. After that, this theme continues
                  to determine the Window background behind the Flutter UI. -->
             <meta-data
-              android:name="io.flutter.embedding.android.NormalTheme"
-              android:resource="@style/NormalTheme"
-              />
+                android:name="io.flutter.embedding.android.NormalTheme"
+                android:resource="@style/NormalTheme" />
             <!-- Displays an Android View that continues showing the launch screen
                  Drawable until Flutter paints its first frame, then this splash
                  screen fades out. A splash screen is useful to avoid any visual
                  gap between the end of Android's launch screen and the painting of
                  Flutter's first frame. -->
             <meta-data
-              android:name="io.flutter.embedding.android.SplashScreenDrawable"
-              android:resource="@drawable/launch_background"
-              />
+                android:name="io.flutter.embedding.android.SplashScreenDrawable"
+                android:resource="@drawable/launch_background" />
             <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-                <category android:name="android.intent.category.LAUNCHER"/>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
         <!-- Don't delete the meta-data below.

BIN
android/app/src/main/res/drawable-hdpi/ic_launcher.png


BIN
android/app/src/main/res/drawable-mdpi/ic_launcher.png


BIN
android/app/src/main/res/drawable-xhdpi/ic_launcher.png


BIN
android/app/src/main/res/drawable-xxhdpi/ic_launcher.png


+ 3 - 0
android/app/src/profile/AndroidManifest.xml

@@ -4,4 +4,7 @@
          to allow setting breakpoints, to provide hot reload, etc.
     -->
     <uses-permission android:name="android.permission.INTERNET"/>
+    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
 </manifest>

+ 5 - 96
lib/main.dart

@@ -1,4 +1,5 @@
 import 'package:flutter/material.dart';
+import 'package:flutter_audio_recorder/pages/home_page.dart';
 
 void main() {
   runApp(const MyApp());
@@ -7,109 +8,17 @@ void main() {
 class MyApp extends StatelessWidget {
   const MyApp({Key? key}) : super(key: key);
 
-  // This widget is the root of your application.
   @override
   Widget build(BuildContext context) {
     return MaterialApp(
-      title: 'Flutter Demo',
+      title: '录音机',
+      debugShowCheckedModeBanner: false,
       theme: ThemeData(
-        // This is the theme of your application.
-        //
-        // Try running your application with "flutter run". You'll see the
-        // application has a blue toolbar. Then, without quitting the app, try
-        // changing the primarySwatch below to Colors.green and then invoke
-        // "hot reload" (press "r" in the console where you ran "flutter run",
-        // or simply save your changes to "hot reload" in a Flutter IDE).
-        // Notice that the counter didn't reset back to zero; the application
-        // is not restarted.
         primarySwatch: Colors.blue,
-      ),
-      home: const MyHomePage(title: 'Flutter Demo Home Page'),
-    );
-  }
-}
-
-class MyHomePage extends StatefulWidget {
-  const MyHomePage({Key? key, required this.title}) : super(key: key);
+        visualDensity: VisualDensity.adaptivePlatformDensity,
 
-  // This widget is the home page of your application. It is stateful, meaning
-  // that it has a State object (defined below) that contains fields that affect
-  // how it looks.
-
-  // This class is the configuration for the state. It holds the values (in this
-  // case the title) provided by the parent (in this case the App widget) and
-  // used by the build method of the State. Fields in a Widget subclass are
-  // always marked "final".
-
-  final String title;
-
-  @override
-  State<MyHomePage> createState() => _MyHomePageState();
-}
-
-class _MyHomePageState extends State<MyHomePage> {
-  int _counter = 0;
-
-  void _incrementCounter() {
-    setState(() {
-      // This call to setState tells the Flutter framework that something has
-      // changed in this State, which causes it to rerun the build method below
-      // so that the display can reflect the updated values. If we changed
-      // _counter without calling setState(), then the build method would not be
-      // called again, and so nothing would appear to happen.
-      _counter++;
-    });
-  }
-
-  @override
-  Widget build(BuildContext context) {
-    // This method is rerun every time setState is called, for instance as done
-    // by the _incrementCounter method above.
-    //
-    // The Flutter framework has been optimized to make rerunning build methods
-    // fast, so that you can just rebuild anything that needs updating rather
-    // than having to individually change instances of widgets.
-    return Scaffold(
-      appBar: AppBar(
-        // Here we take the value from the MyHomePage object that was created by
-        // the App.build method, and use it to set our appbar title.
-        title: Text(widget.title),
-      ),
-      body: Center(
-        // Center is a layout widget. It takes a single child and positions it
-        // in the middle of the parent.
-        child: Column(
-          // Column is also a layout widget. It takes a list of children and
-          // arranges them vertically. By default, it sizes itself to fit its
-          // children horizontally, and tries to be as tall as its parent.
-          //
-          // Invoke "debug painting" (press "p" in the console, choose the
-          // "Toggle Debug Paint" action from the Flutter Inspector in Android
-          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
-          // to see the wireframe for each widget.
-          //
-          // Column has various properties to control how it sizes itself and
-          // how it positions its children. Here we use mainAxisAlignment to
-          // center the children vertically; the main axis here is the vertical
-          // axis because Columns are vertical (the cross axis would be
-          // horizontal).
-          mainAxisAlignment: MainAxisAlignment.center,
-          children: <Widget>[
-            const Text(
-              'You have pushed the button this many times:',
-            ),
-            Text(
-              '$_counter',
-              style: Theme.of(context).textTheme.headline4,
-            ),
-          ],
-        ),
       ),
-      floatingActionButton: FloatingActionButton(
-        onPressed: _incrementCounter,
-        tooltip: 'Increment',
-        child: const Icon(Icons.add),
-      ), // This trailing comma makes auto-formatting nicer for build methods.
+      home: const HomePage(),
     );
   }
 }

+ 101 - 0
lib/pages/home_page.dart

@@ -0,0 +1,101 @@
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter_audio_recorder/views/recorder.dart';
+import 'package:flutter_audio_recorder/views/records.dart';
+import 'package:path_provider/path_provider.dart';
+
+class HomePage extends StatefulWidget {
+  const HomePage({Key? key}) : super(key: key);
+
+  @override
+  _HomePageState createState() => _HomePageState();
+}
+
+class _HomePageState extends State<HomePage> {
+  late Directory? appDir;
+  late List<String>? records;
+
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      floatingActionButton: FloatingActionButton(
+        onPressed: () {},
+        child: InkWell(
+          child: const Icon(Icons.mic),
+          onTap: () {
+            show(context);
+          },
+        ),
+      ),
+      appBar: AppBar(
+        title: const Text(
+          "录音机App",
+          style: TextStyle(color: Colors.white),
+        ),
+        centerTitle: true,
+      ),
+      body: Column(
+        children: [
+          Expanded(
+            flex: 2,
+            child: Records(
+              records: records!,
+            ),
+          ),
+        ],
+      ),
+    );
+  }
+
+  _onFinish() {
+    records!.clear();
+    appDir!.list().listen((onData) {
+      records!.add(onData.path);
+    }).onDone(() {
+      records!.sort();
+      records = records!.reversed.toList();
+      setState(() {});
+    });
+  }
+
+  //底部弹出录音按钮模态框
+  void show(BuildContext context) {
+    showModalBottomSheet<void>(
+      context: context,
+      builder: (BuildContext context) {
+        return Container(
+          height: 200,
+          color: Colors.white70,
+          child: RecorderView(
+            save: _onFinish,
+          ),
+        );
+      },
+    );
+  }
+
+  @override
+  void initState() {
+    super.initState();
+    records = [];
+    getExternalStorageDirectory().then((value) {
+      appDir = value!;
+      Directory appDirec = Directory("${appDir!.path}/Audiorecords/");
+      appDir = appDirec;
+      appDir!.list().listen((onData) {
+        records!.add(onData.path);
+      }).onDone(() {
+        records = records!.reversed.toList();
+        setState(() {});
+      });
+    });
+  }
+
+  @override
+  void dispose() {
+    appDir = null;
+    records = null;
+    super.dispose();
+  }
+}

+ 283 - 0
lib/views/recorder.dart

@@ -0,0 +1,283 @@
+import 'dart:async';
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:fluttertoast/fluttertoast.dart';
+import 'package:path_provider/path_provider.dart';
+import 'package:permission_handler/permission_handler.dart';
+
+class RecorderView extends StatefulWidget {
+  final Function save;
+
+  const RecorderView({Key? key, required this.save}) : super(key: key);
+
+  @override
+  _RecorderViewState createState() => _RecorderViewState();
+}
+
+class _RecorderViewState extends State<RecorderView> {
+  IconData _recordIcon = Icons.mic_none;
+  MaterialColor colo = Colors.orange;
+  RecordingStatus _currentStatus = RecordingStatus.Unset;
+  bool stop = false;
+  Recording? _current;
+
+  // Recorder properties
+  late FlutterAudioRecorder? audioRecorder;
+
+  @override
+  void initState() {
+    super.initState();
+    checkPermission();
+  }
+
+  // 权限检测
+  void checkPermission() async {
+    if (await Permission.contacts.request().isGranted) {
+      // Either the permission was already granted before or the user just granted it.
+    }
+
+// You can request multiple permissions at once.
+    Map<Permission, PermissionStatus> statuses = await [
+      Permission.microphone,
+      Permission.storage,
+    ].request();
+    //bool hasPermission = await FlutterAudioRecorder.hasPermissions ?? false;
+    if (statuses[Permission.microphone] == PermissionStatus.granted) {
+      _currentStatus = RecordingStatus.Initialized;
+      _recordIcon = Icons.mic;
+    } else {}
+  }
+
+  @override
+  void dispose() {
+    _currentStatus = RecordingStatus.Unset;
+    audioRecorder = null;
+    super.dispose();
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Stack(
+      alignment: Alignment.center,
+      children: [
+        Column(
+          children: [
+            const SizedBox(
+              height: 20,
+            ),
+            Text(
+              (_current == null)
+                  ? "0:0:0:0"
+                  : _current!.duration.toString(),
+              style: const TextStyle(color: Colors.black, fontSize: 20),
+            ),
+            const SizedBox(
+              height: 20,
+            ),
+            stop == false
+                ? RaisedButton(
+                    color: Colors.orange,
+                    onPressed: () async {
+                      await _onRecordButtonPressed();
+                      setState(() {});
+                    },
+                    shape: RoundedRectangleBorder(
+                      borderRadius: BorderRadius.circular(10),
+                    ),
+                    child: Column(
+                      children: [
+                        Container(
+                          width: 80,
+                          height: 80,
+                          child: Icon(
+                            _recordIcon,
+                            color: Colors.white,
+                            size: 80,
+                          ),
+                        ),
+                        const Padding(
+                          padding: EdgeInsets.all(8.0),
+                          child: Text(
+                            "Write Dailry",
+                            style: TextStyle(color: Colors.white),
+                          ),
+                        )
+                      ],
+                    ),
+                  )
+                : Padding(
+                    padding: const EdgeInsets.all(8.0),
+                    child: Row(
+                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                      children: [
+                        RaisedButton(
+                          color: colo,
+                          onPressed: () async {
+                            await _onRecordButtonPressed();
+                            setState(() {});
+                          },
+                          shape: RoundedRectangleBorder(
+                            borderRadius: BorderRadius.circular(10),
+                          ),
+                          child: Container(
+                            width: 80,
+                            height: 80,
+                            child: Icon(
+                              _recordIcon,
+                              color: Colors.white,
+                              size: 50,
+                            ),
+                          ),
+                        ),
+                        RaisedButton(
+                          color: Colors.orange,
+                          onPressed: _currentStatus != RecordingStatus.Unset
+                              ? _stop
+                              : null,
+                          shape: RoundedRectangleBorder(
+                            borderRadius: BorderRadius.circular(10),
+                          ),
+                          child: Container(
+                            width: 80,
+                            height: 80,
+                            child: Icon(
+                              Icons.stop,
+                              color: Colors.white,
+                              size: 50,
+                            ),
+                          ),
+                        ),
+                      ],
+                    ),
+                  ),
+          ],
+        ),
+      ],
+    );
+  }
+
+  Future<void> _onRecordButtonPressed() async {
+    switch (_currentStatus) {
+      case RecordingStatus.Initialized:
+        {
+          _recordo();
+          break;
+        }
+      case RecordingStatus.Recording:
+        {
+          _pause();
+          break;
+        }
+      case RecordingStatus.Paused:
+        {
+          _resume();
+          break;
+        }
+      case RecordingStatus.Stopped:
+        {
+          _recordo();
+          break;
+        }
+      default:
+        break;
+    }
+  }
+
+  _initial() async {
+    Directory? appDir = await getExternalStorageDirectory();
+    String jrecord = 'Audiorecords';
+    String dato = "${DateTime.now().millisecondsSinceEpoch.toString()}.wav";
+    Directory appDirec = Directory("${appDir!.path}/$jrecord/");
+    if (await appDirec.exists()) {
+      String patho = "${appDirec.path}$dato";
+      audioRecorder = FlutterAudioRecorder(patho, audioFormat: AudioFormat.WAV);
+      await audioRecorder!.initialized;
+    } else {
+      appDirec.create(recursive: true);
+      Fluttertoast.showToast(msg: "Start Recording , Press Start");
+      String patho = "${appDirec.path}$dato";
+      audioRecorder = FlutterAudioRecorder(patho, audioFormat: AudioFormat.WAV);
+      await audioRecorder!.initialized;
+    }
+  }
+
+  _start() async {
+    await audioRecorder!.start();
+    var recording = await audioRecorder!.current(channel: 0);
+    setState(() {
+      _current = recording!;
+    });
+
+    const tick = const Duration(milliseconds: 50);
+    Timer.periodic(tick, (Timer t) async {
+      if (_currentStatus == RecordingStatus.Stopped) {
+        t.cancel();
+      }
+
+      var current = await audioRecorder!.current(channel: 0);
+      // print(current.status);
+      setState(() {
+        _current = current!;
+        _currentStatus = _current!.status!;
+      });
+    });
+  }
+
+  _resume() async {
+    await audioRecorder!.resume();
+    Fluttertoast.showToast(msg: "Resume Recording");
+    setState(() {
+      _recordIcon = Icons.pause;
+      colo = Colors.red;
+    });
+  }
+
+  _pause() async {
+    await audioRecorder!.pause();
+    Fluttertoast.showToast(msg: "Pause Recording");
+    setState(() {
+      _recordIcon = Icons.mic;
+      colo = Colors.green;
+    });
+  }
+
+  _stop() async {
+    var result = await audioRecorder!.stop();
+    Fluttertoast.showToast(msg: "Stop Recording , File Saved");
+    widget.save();
+    setState(() {
+      _current = result!;
+      _currentStatus = _current!.status!;
+      _current!.duration = null;
+      _recordIcon = Icons.mic;
+      stop = false;
+    });
+  }
+
+  Future<void> _recordo() async {
+    Map<Permission, PermissionStatus> statuses = await [
+      Permission.microphone,
+      Permission.storage,
+    ].request();
+    print(statuses[Permission.microphone]);
+    print(statuses[Permission.storage]);
+    if (statuses[Permission.microphone] == PermissionStatus.granted) {
+      /* }
+    bool hasPermission = await FlutterAudioRecorder.hasPermissions ?? false;
+
+    if (hasPermission) {*/
+      await _initial();
+      await _start();
+      Fluttertoast.showToast(msg: "Start Recording");
+      setState(() {
+        _currentStatus = RecordingStatus.Recording;
+        _recordIcon = Icons.pause;
+        colo = Colors.red;
+        stop = true;
+      });
+    } else {
+      Fluttertoast.showToast(msg: "Allow App To Use Mic");
+    }
+  }
+}

+ 191 - 0
lib/views/records.dart

@@ -0,0 +1,191 @@
+import 'dart:io';
+
+import 'package:audioplayers/audioplayers.dart';
+import 'package:flutter/material.dart';
+import 'package:fluttertoast/fluttertoast.dart';
+
+// 录音列表
+class Records extends StatefulWidget {
+  final List<String> records;
+
+  const Records({
+    Key? key,
+    required this.records,
+  }) : super(key: key);
+
+  @override
+  _RecordsState createState() => _RecordsState();
+}
+
+class _RecordsState extends State<Records> {
+  late int _totalTime;
+  late int _currentTime;
+  double _percent = 0.0;
+  int _selected = -1;
+  bool isPlay = false;
+  AudioPlayer advancedPlayer = AudioPlayer();
+
+  @override
+  Widget build(BuildContext context) {
+    return ListView.builder(
+      itemCount: widget.records.length,
+      shrinkWrap: true,
+      reverse: true,
+      itemBuilder: (BuildContext context, int i) {
+        return Card(
+          elevation: 5,
+          child: ExpansionTile(
+            title: Text(
+              'Record ${widget.records.length - i}',
+              style: TextStyle(color: Colors.black),
+            ),
+            subtitle: Text(
+              _getTime(filePath: widget.records.elementAt(i)),
+              style: TextStyle(color: Colors.black38),
+            ),
+            onExpansionChanged: ((newState) {
+              if (newState) {
+                setState(() {
+                  _selected = i;
+                });
+              }
+            }),
+            children: [
+              Container(
+                height: 100,
+                padding: const EdgeInsets.all(10),
+                child: Column(
+                  mainAxisAlignment: MainAxisAlignment.center,
+                  children: [
+                    LinearProgressIndicator(
+                      minHeight: 5,
+                      backgroundColor: Colors.black,
+                      valueColor: AlwaysStoppedAnimation<Color>(Colors.green),
+                      value: _selected == i ? _percent : 0,
+                    ),
+                    Row(
+                      children: [
+                        (isPlay)
+                            ? _Presso(
+                                ico: Icons.pause,
+                                onPressed: () {
+                                  setState(() {
+                                    isPlay = false;
+                                  });
+                                  advancedPlayer.pause();
+                                })
+                            : _Presso(
+                                ico: Icons.play_arrow,
+                                onPressed: () {
+                                  setState(() {
+                                    isPlay = true;
+                                  });
+                                  advancedPlayer.play(
+                                      widget.records.elementAt(i),
+                                      isLocal: true);
+                                  setState(() {});
+                                  setState(() {
+                                    _selected = i;
+                                    _percent = 0.0;
+                                  });
+                                  advancedPlayer.onPlayerCompletion.listen((_) {
+                                    setState(() {
+                                      _percent = 0.0;
+                                    });
+                                  });
+                                  advancedPlayer.onDurationChanged
+                                      .listen((duration) {
+                                    setState(() {
+                                      _totalTime = duration.inMicroseconds;
+                                    });
+                                  });
+                                  advancedPlayer.onAudioPositionChanged
+                                      .listen((duration) {
+                                    setState(() {
+                                      _currentTime = duration.inMicroseconds;
+                                      _percent = _currentTime.toDouble() /
+                                          _totalTime.toDouble();
+                                    });
+                                  });
+                                }),
+                        _Presso(
+                            ico: Icons.stop,
+                            onPressed: () {
+                              advancedPlayer.stop();
+                              setState(() {
+                                _percent = 0.0;
+                              });
+                            }),
+                        _Presso(
+                            ico: Icons.delete,
+                            onPressed: () {
+                              Directory appDirec =
+                                  Directory(widget.records.elementAt(i));
+                              appDirec.delete(recursive: true);
+                              Fluttertoast.showToast(msg: "File Deleted");
+                              setState(() {
+                                widget.records
+                                    .remove(widget.records.elementAt(i));
+                              });
+                            }),
+                        _Presso(
+                            ico: Icons.share,
+                            onPressed: () {
+                              Directory appDirec =
+                                  Directory(widget.records.elementAt(i));
+                              List<String> list = List.empty(growable: true);
+                              list.add(appDirec.path);
+                              // Share.shareFiles(list);
+                            }),
+                      ],
+                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+                    ),
+                  ],
+                ),
+              ),
+            ],
+          ),
+        );
+      },
+    );
+  }
+
+  String _getTime({required String filePath}) {
+    String fromPath = filePath.substring(
+        filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.'));
+    if (fromPath.startsWith("1", 0)) {
+      DateTime dateTime =
+          DateTime.fromMillisecondsSinceEpoch(int.parse(fromPath));
+      int year = dateTime.year;
+      int month = dateTime.month;
+      int day = dateTime.day;
+      int hour = dateTime.hour;
+      int min = dateTime.minute;
+      String dato = '$year-$month-$day--$hour:$min';
+      return dato;
+    } else {
+      return "No Date";
+    }
+  }
+}
+
+class _Presso extends StatelessWidget {
+  final IconData ico;
+  final VoidCallback onPressed;
+
+  const _Presso({Key? key, required this.ico, required this.onPressed})
+      : super(key: key);
+
+  @override
+  Widget build(BuildContext context) {
+    return ButtonTheme(
+      minWidth: 48.0,
+      child: RaisedButton(
+          child: Icon(
+            ico,
+            color: Colors.white,
+          ),
+          onPressed: onPressed),
+    );
+  }
+}

+ 8 - 0
local.properties

@@ -0,0 +1,8 @@
+## This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+#
+# Location of the SDK. This is only used by Gradle.
+# For customization when using a Version Control System, please read the
+# header note.
+#Mon Nov 29 16:51:21 CST 2021
+sdk.dir=D\:\\Program-Files\\android-sdk-windows

+ 168 - 1
pubspec.lock

@@ -8,6 +8,13 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "2.8.1"
+  audioplayers:
+    dependency: "direct main"
+    description:
+      name: audioplayers
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "0.20.1"
   boolean_selector:
     dependency: transitive
     description:
@@ -43,6 +50,13 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.15.0"
+  crypto:
+    dependency: transitive
+    description:
+      name: crypto
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.0.1"
   cupertino_icons:
     dependency: "direct main"
     description:
@@ -57,6 +71,20 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.2.0"
+  ffi:
+    dependency: transitive
+    description:
+      name: ffi
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "1.1.2"
+  file:
+    dependency: transitive
+    description:
+      name: file
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "6.1.2"
   flutter:
     dependency: "direct main"
     description: flutter
@@ -74,6 +102,39 @@ packages:
     description: flutter
     source: sdk
     version: "0.0.0"
+  flutter_web_plugins:
+    dependency: transitive
+    description: flutter
+    source: sdk
+    version: "0.0.0"
+  fluttertoast:
+    dependency: "direct main"
+    description:
+      name: fluttertoast
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "8.0.8"
+  http:
+    dependency: transitive
+    description:
+      name: http
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "0.13.4"
+  http_parser:
+    dependency: transitive
+    description:
+      name: http_parser
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "4.0.0"
+  js:
+    dependency: transitive
+    description:
+      name: js
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "0.6.3"
   lints:
     dependency: transitive
     description:
@@ -102,6 +163,90 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.8.0"
+  path_provider:
+    dependency: "direct main"
+    description:
+      name: path_provider
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.0.7"
+  path_provider_android:
+    dependency: transitive
+    description:
+      name: path_provider_android
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.0.9"
+  path_provider_ios:
+    dependency: transitive
+    description:
+      name: path_provider_ios
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.0.7"
+  path_provider_linux:
+    dependency: transitive
+    description:
+      name: path_provider_linux
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.1.2"
+  path_provider_macos:
+    dependency: transitive
+    description:
+      name: path_provider_macos
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.0.3"
+  path_provider_platform_interface:
+    dependency: transitive
+    description:
+      name: path_provider_platform_interface
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.0.1"
+  path_provider_windows:
+    dependency: transitive
+    description:
+      name: path_provider_windows
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.0.4"
+  permission_handler:
+    dependency: "direct main"
+    description:
+      name: permission_handler
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "8.3.0"
+  permission_handler_platform_interface:
+    dependency: transitive
+    description:
+      name: permission_handler_platform_interface
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.7.0"
+  platform:
+    dependency: transitive
+    description:
+      name: platform
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.0.2"
+  plugin_platform_interface:
+    dependency: transitive
+    description:
+      name: plugin_platform_interface
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.0.2"
+  process:
+    dependency: transitive
+    description:
+      name: process
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "4.2.4"
   sky_engine:
     dependency: transitive
     description: flutter
@@ -156,6 +301,13 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.3.0"
+  uuid:
+    dependency: transitive
+    description:
+      name: uuid
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.0.5"
   vector_math:
     dependency: transitive
     description:
@@ -163,5 +315,20 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "2.1.0"
+  win32:
+    dependency: transitive
+    description:
+      name: win32
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "2.3.1"
+  xdg_directories:
+    dependency: transitive
+    description:
+      name: xdg_directories
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "0.2.0"
 sdks:
-  dart: ">=2.12.0 <3.0.0"
+  dart: ">=2.14.0 <3.0.0"
+  flutter: ">=2.5.0"

+ 6 - 65
pubspec.yaml

@@ -1,89 +1,30 @@
 name: flutter_audio_recorder
 description: A new Flutter application.
-
-# The following line prevents the package from being accidentally published to
-# pub.dev using `flutter pub publish`. This is preferred for private packages.
 publish_to: 'none' # Remove this line if you wish to publish to pub.dev
-
-# The following defines the version and build number for your application.
-# A version number is three numbers separated by dots, like 1.2.43
-# followed by an optional build number separated by a +.
-# Both the version and the builder number may be overridden in flutter
-# build by specifying --build-name and --build-number, respectively.
-# In Android, build-name is used as versionName while build-number used as versionCode.
-# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
-# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
-# Read more about iOS versioning at
-# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 version: 1.0.0+1
 
 environment:
   sdk: ">=2.12.0 <3.0.0"
-
-# Dependencies specify other packages that your package needs in order to work.
-# To automatically upgrade your package dependencies to the latest versions
-# consider running `flutter pub upgrade --major-versions`. Alternatively,
-# dependencies can be manually updated by changing the version numbers below to
-# the latest version available on pub.dev. To see which dependencies have newer
-# versions available, run `flutter pub outdated`.
 dependencies:
   flutter:
     sdk: flutter
 
-
-  # The following adds the Cupertino Icons font to your application.
-  # Use with the CupertinoIcons class for iOS style icons.
   cupertino_icons: ^1.0.3
+  fluttertoast: ^8.0.8
+  permission_handler: ^8.1.4+1
+  path_provider: ^2.0.7
+  audioplayers: ^0.20.1
 
+#  rflutter_alert: ^2.0.2
+#  share: ^2.0.4
 dev_dependencies:
   flutter_test:
     sdk: flutter
-
-  # The "flutter_lints" package below contains a set of recommended lints to
-  # encourage good coding practices. The lint set provided by the package is
-  # activated in the `analysis_options.yaml` file located at the root of your
-  # package. See that file for information about deactivating specific lint
-  # rules and activating additional ones.
   flutter_lints: ^1.0.0
 
-# For information on the generic Dart part of this file, see the
-# following page: https://dart.dev/tools/pub/pubspec
-
-# The following section is specific to Flutter.
 flutter:
 
-  # The following line ensures that the Material Icons font is
-  # included with your application, so that you can use the icons in
-  # the material Icons class.
   uses-material-design: true
-
-  # To add assets to your application, add an assets section, like this:
   # assets:
   #   - images/a_dot_burr.jpeg
   #   - images/a_dot_ham.jpeg
-
-  # An image asset can refer to one or more resolution-specific "variants", see
-  # https://flutter.dev/assets-and-images/#resolution-aware.
-
-  # For details regarding adding assets from package dependencies, see
-  # https://flutter.dev/assets-and-images/#from-packages
-
-  # To add custom fonts to your application, add a fonts section here,
-  # in this "flutter" section. Each entry in this list should have a
-  # "family" key with the font family name, and a "fonts" key with a
-  # list giving the asset and other descriptors for the font. For
-  # example:
-  # fonts:
-  #   - family: Schyler
-  #     fonts:
-  #       - asset: fonts/Schyler-Regular.ttf
-  #       - asset: fonts/Schyler-Italic.ttf
-  #         style: italic
-  #   - family: Trajan Pro
-  #     fonts:
-  #       - asset: fonts/TrajanPro.ttf
-  #       - asset: fonts/TrajanPro_Bold.ttf
-  #         weight: 700
-  #
-  # For details regarding fonts from package dependencies,
-  # see https://flutter.dev/custom-fonts/#from-packages