Pop on error

This commit is contained in:
Christian Pauly 2020-03-15 11:49:59 +01:00
parent 9b31f72296
commit 4342f0a8b6

View file

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