We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package version
record: ^5.1.2
Environment
Development: MacOS 14.5 Debug Device: iOS 15.7
Describe the bug
I have a Button, it will call start or stop record when tap, and it will execute those code
Button
Future<void> _startRecord() async { if (!await _audioRecorder.hasPermission()) { if (mounted) { AppLocalizations.of(context)!.audioRecordWithoutPermission; } return; } _recordContentBuilder = BytesBuilder(); var stream = await _audioRecorder .startStream(const RecordConfig(encoder: AudioEncoder.pcm16bits)); stream.listen((data) async { _recordContentBuilder?.add(data.toList()); }); _audioRecorder .onAmplitudeChanged(const Duration(milliseconds: 100)) .listen((amplitude) { _audioWaveStreamController.sink.add(amplitude.current); }); } Future<void> _stopRecording() async { if (!await _audioRecorder.isRecording()) { return; } await _audioRecorder.stop(); _recordStartTime = null; _timer?.cancel(); _timer = null; if (mounted) { Navigator.of(context).pop(_recordContentBuilder!.toBytes()); } }
when I click this button very quickly, it will continue raise many exception like this
... [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(record, Recorder has not yet been created or has already been disposed., null, null) #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7) #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18) <asynchronous suspension> #2 RecordMethodChannel.isRecording (package:record_platform_interface/src/record_method_channel.dart:40:20) <asynchronous suspension> #3 AudioRecorder._updateAmplitudeAtInterval.shouldUpdate (package:record/src/record.dart:210:24) <asynchronous suspension> #4 AudioRecorder._updateAmplitudeAtInterval (package:record/src/record.dart:213:9) <asynchronous suspension> [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(record, Recorder has not yet been created or has already been disposed., null, null) #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7) #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18) <asynchronous suspension> #2 RecordMethodChannel.isRecording (package:record_platform_interface/src/record_method_channel.dart:40:20) <asynchronous suspension> #3 AudioRecorder._updateAmplitudeAtInterval.shouldUpdate (package:record/src/record.dart:210:24) <asynchronous suspension> #4 AudioRecorder._updateAmplitudeAtInterval (package:record/src/record.dart:213:9) <asynchronous suspension> ...
The text was updated successfully, but these errors were encountered:
Repeated clicks cause _startRecord to enter multiple executions repeatedly. Add a state to avoid this. Thank you to the author.
_startRecord
Sorry, something went wrong.
c422bd0
No branches or pull requests
Package version
Environment
Describe the bug
I have a
Button
, it will call start or stop record when tap, and it will execute those codewhen I click this button very quickly, it will continue raise many exception like this
The text was updated successfully, but these errors were encountered: