fix: Keep display alive while recording

This commit is contained in:
Christian Pauly 2021-08-11 21:17:11 +02:00
parent b3e3419508
commit ddba6c2ad6
3 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:path_provider/path_provider.dart';
import 'package:record/record.dart';
import 'package:wakelock/wakelock.dart';
class RecordingDialog extends StatefulWidget {
static const String recordingFileType = 'aac';
@ -35,6 +36,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
setState(() => error = true);
return;
}
await Wakelock.enable();
await _audioRecorder.start(
path: _recordedPath, encoder: AudioEncoder.AAC);
setState(() => _duration = Duration.zero);
@ -55,6 +57,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
@override
void dispose() {
Wakelock.disable();
_recorderSubscription?.cancel();
_audioRecorder.stop();
super.dispose();

View File

@ -1501,7 +1501,7 @@ packages:
source: hosted
version: "1.2.0+11"
wakelock:
dependency: transitive
dependency: "direct main"
description:
name: wakelock
url: "https://pub.dartlang.org"

View File

@ -68,6 +68,7 @@ dependencies:
universal_html: ^2.0.8
url_launcher: ^6.0.9
vrouter: 1.2.0+11
wakelock: ^0.5.3+3
dev_dependencies:
dapackages: ^1.6.0