方法 'openAudioSession' 没有为类型 'FlutterSoundRecorder' 定义
The method 'openAudioSession' isn't defined for the type 'FlutterSoundRecorder'
我正在编写一个用于使用 flutter_sound 包
录制语音的 flutter 应用程序
environment:
sdk: ">=2.15.1 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_sound: ^9.1.2
permission_handler: ^8.3.0
import 'package:flutter_sound/flutter_sound.dart';
import 'package:permission_handler/permission_handler.dart';
Future init() async {
_audioRecorder = FlutterSoundRecorder();
final status = await Permission.microphone.request();
if (status != PermissionStatus.granted){
throw RecordingPermissionException('Microphone permission denied.');
}
await _audioRecorder!.openAudioSession();
_isRecorderInitiated = true;
}
我遇到这个错误
The method 'openAudioSession' isn't defined for the type 'FlutterSoundRecorder'.
有人能帮我找出代码有什么问题吗?
9版本好像已经removed了,但是文档还没有更新。您可以改用 openRecorder()
或切换到旧版本的库。
我正在编写一个用于使用 flutter_sound 包
录制语音的 flutter 应用程序environment:
sdk: ">=2.15.1 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_sound: ^9.1.2
permission_handler: ^8.3.0
import 'package:flutter_sound/flutter_sound.dart';
import 'package:permission_handler/permission_handler.dart';
Future init() async {
_audioRecorder = FlutterSoundRecorder();
final status = await Permission.microphone.request();
if (status != PermissionStatus.granted){
throw RecordingPermissionException('Microphone permission denied.');
}
await _audioRecorder!.openAudioSession();
_isRecorderInitiated = true;
}
我遇到这个错误
The method 'openAudioSession' isn't defined for the type 'FlutterSoundRecorder'.
有人能帮我找出代码有什么问题吗?
9版本好像已经removed了,但是文档还没有更新。您可以改用 openRecorder()
或切换到旧版本的库。