Pop on error

This commit is contained in:
Christian Pauly 2020-03-15 11:49:59 +01:00
parent 9b31f72296
commit 4342f0a8b6
1 changed files with 19 additions and 8 deletions

View File

@ -20,15 +20,21 @@ class _RecordingDialogState extends State<RecordingDialog> {
StreamSubscription _recorderSubscription;
bool error = false;
void startRecording() async {
await flutterSound.startRecorder(
codec: t_CODEC.CODEC_AAC,
);
_recorderSubscription = flutterSound.onRecorderStateChanged.listen((e) {
DateTime date =
DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
setState(() => time = DateFormat('mm:ss:SS', 'en_US').format(date));
});
try {
await flutterSound.startRecorder(
codec: t_CODEC.CODEC_AAC,
);
_recorderSubscription = flutterSound.onRecorderStateChanged.listen((e) {
DateTime date =
DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
setState(() => time = DateFormat('mm:ss:SS', 'en_US').format(date));
});
} catch (e) {
error = true;
}
}
@override
@ -46,6 +52,11 @@ class _RecordingDialogState extends State<RecordingDialog> {
@override
Widget build(BuildContext context) {
if (error) {
Timer(Duration(seconds: 1), () {
Navigator.of(context).pop();
});
}
return AlertDialog(
content: Row(
children: <Widget>[