RecordAudioCubit constructor

RecordAudioCubit({
  1. required dynamic onRecordEnd(
    1. String?
    ),
  2. required dynamic onRecordStart()?,
  3. required dynamic onRecordCancel()?,
  4. required Duration? maxRecordLength,
})

Implementation

RecordAudioCubit({
  required this.onRecordEnd,
  required this.onRecordStart,
  required this.onRecordCancel,
  required this.maxRecordLength,
}) : super(RecordAudioReady()) {
  _myRecorder.openAudioSession().then((value) {
    _myRecorder.setSubscriptionDuration(const Duration(milliseconds: 200));
    recorderStream = _myRecorder.onProgress!.listen((event) {
      Duration current = event.duration;
      currentDuration.value = current;
      if (maxRecordLength != null) {
        if (current.inMilliseconds >= maxRecordLength!.inMilliseconds) {
          log('[chat_composer] 🔴 Audio passed max length');
          stopRecord();
        }
      }
    });
  });
}