Pop on error

onboarding
Christian Pauly 5 years ago
parent 6d781128ea
commit 1f8aef2740

@ -20,15 +20,21 @@ class _RecordingDialogState extends State<RecordingDialog> {
StreamSubscription _recorderSubscription; StreamSubscription _recorderSubscription;
bool error = false;
void startRecording() async { void startRecording() async {
await flutterSound.startRecorder( try {
codec: t_CODEC.CODEC_AAC, await flutterSound.startRecorder(
); codec: t_CODEC.CODEC_AAC,
_recorderSubscription = flutterSound.onRecorderStateChanged.listen((e) { );
DateTime date = _recorderSubscription = flutterSound.onRecorderStateChanged.listen((e) {
DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt()); DateTime date =
setState(() => time = DateFormat('mm:ss:SS', 'en_US').format(date)); DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
}); 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>[

Loading…
Cancel
Save