From 991bba253509cf3427f1cd6892e161311768c2ba Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sat, 28 Oct 2023 10:29:22 +0200 Subject: [PATCH] build: Update record package --- lib/pages/chat/chat.dart | 2 +- lib/pages/chat/recording_dialog.dart | 17 ++++--- macos/Flutter/GeneratedPluginRegistrant.swift | 4 +- pubspec.lock | 44 +++++++++++-------- pubspec.yaml | 2 +- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index e17226fa..23b77c70 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -626,7 +626,7 @@ class ChatController extends State { } } - if (await Record().hasPermission() == false) return; + if (await AudioRecorder().hasPermission() == false) return; final result = await showDialog( context: context, useRootNavigator: false, diff --git a/lib/pages/chat/recording_dialog.dart b/lib/pages/chat/recording_dialog.dart index 1057ce6a..0629240d 100644 --- a/lib/pages/chat/recording_dialog.dart +++ b/lib/pages/chat/recording_dialog.dart @@ -28,7 +28,7 @@ class RecordingDialogState extends State { bool error = false; String? _recordedPath; - final _audioRecorder = Record(); + final _audioRecorder = AudioRecorder(); final List amplitudeTimeline = []; static const int bitRate = 64000; @@ -37,7 +37,7 @@ class RecordingDialogState extends State { Future startRecording() async { try { final tempDir = await getTemporaryDirectory(); - _recordedPath = + final path = _recordedPath = '${tempDir.path}/recording${DateTime.now().microsecondsSinceEpoch}.${RecordingDialog.recordingFileType}'; final result = await _audioRecorder.hasPermission(); @@ -55,10 +55,15 @@ class RecordingDialogState extends State { : AudioEncoder.aacLc; await _audioRecorder.start( - encoder: audioCodec, - path: _recordedPath, - bitRate: bitRate, - samplingRate: samplingRate, + RecordConfig( + encoder: audioCodec, + autoGain: true, + noiseSuppress: true, + echoCancel: true, + bitRate: bitRate, + sampleRate: samplingRate, + ), + path: path, ); setState(() => _duration = Duration.zero); _recorderSubscription?.cancel(); diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index e47880af..8f5de20f 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -24,7 +24,7 @@ import macos_window_utils import package_info_plus import pasteboard import path_provider_foundation -import record_macos +import record_darwin import share_plus import shared_preferences_foundation import sqflite @@ -53,7 +53,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) - RecordMacosPlugin.register(with: registry.registrar(forPlugin: "RecordMacosPlugin")) + RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) diff --git a/pubspec.lock b/pubspec.lock index b9b79888..225d998a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1473,50 +1473,58 @@ packages: dependency: "direct main" description: name: record - sha256: f703397f5a60d9b2b655b3acc94ba079b2d9a67dc0725bdb90ef2fee2441ebf7 + sha256: be9b710f42edf94f939dda1a1688e82a68dcd391be0a836c01e639a249f133d3 url: "https://pub.dev" source: hosted - version: "4.4.4" + version: "5.0.1" + record_android: + dependency: transitive + description: + name: record_android + sha256: f2d72c8e86d275967b9e9d1ced58c775958b94d3e2dac3d5416df46d23924ade + url: "https://pub.dev" + source: hosted + version: "1.0.2" + record_darwin: + dependency: transitive + description: + name: record_darwin + sha256: "78dba641ae271e555035ee68b637f7605ba9f8c60ccfd5c03b835e0b77ea201f" + url: "https://pub.dev" + source: hosted + version: "1.0.0" record_linux: dependency: transitive description: name: record_linux - sha256: "348db92c4ec1b67b1b85d791381c8c99d7c6908de141e7c9edc20dad399b15ce" + sha256: "7d0e70cd51635128fe9d37d89bafd6011d7cbba9af8dc323079ae60f23546aef" url: "https://pub.dev" source: hosted - version: "0.4.1" - record_macos: - dependency: transitive - description: - name: record_macos - sha256: d1d0199d1395f05e218207e8cacd03eb9dc9e256ddfe2cfcbbb90e8edea06057 - url: "https://pub.dev" - source: hosted - version: "0.2.2" + version: "0.7.1" record_platform_interface: dependency: transitive description: name: record_platform_interface - sha256: "7a2d4ce7ac3752505157e416e4e0d666a54b1d5d8601701b7e7e5e30bec181b4" + sha256: "3a4b56e94ecd2a0b2b43eb1fa6f94c5b8484334f5d38ef43959c4bf97fb374cf" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "1.0.2" record_web: dependency: transitive description: name: record_web - sha256: "219ffb4ca59b4338117857db56d3ffadbde3169bcaf1136f5f4d4656f4a2372d" + sha256: f1c0427dcf5af68dcfe06439d04771d65f73bd040eb0dcd98fbe4c02263a7d35 url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "1.0.0" record_windows: dependency: transitive description: name: record_windows - sha256: "42d545155a26b20d74f5107648dbb3382dbbc84dc3f1adc767040359e57a1345" + sha256: "326bfbe6f5232dd773ad6b848cd94f78148f02557abff1dd4627d056b688dbdb" url: "https://pub.dev" source: hosted - version: "0.7.1" + version: "1.0.0" remove_emoji: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2aaa5283..48c76437 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -73,7 +73,7 @@ dependencies: qr_code_scanner: ^1.0.0 qr_flutter: ^4.0.0 receive_sharing_intent: ^1.4.5 - record: ^4.4.4 + record: ^5.0.1 scroll_to_index: ^3.0.1 share_plus: ^7.0.0 shared_preferences: ^2.2.0 # Pinned because https://github.com/flutter/flutter/issues/118401