fix: Missing null check

This commit is contained in:
Christian Pauly 2021-08-11 22:04:55 +02:00
parent 47bce19d4a
commit 8ca1151f3e

View File

@ -42,10 +42,11 @@ class _RecordingDialogState extends State<RecordingDialog> {
path: _recordedPath, encoder: AudioEncoder.AAC); path: _recordedPath, encoder: AudioEncoder.AAC);
setState(() => _duration = Duration.zero); setState(() => _duration = Duration.zero);
_recorderSubscription?.cancel(); _recorderSubscription?.cancel();
_recorderSubscription = Timer.periodic(Duration(seconds: 1), (_) async { _recorderSubscription =
Timer.periodic(Duration(milliseconds: 100), (_) async {
_amplitude = await _audioRecorder.getAmplitude(); _amplitude = await _audioRecorder.getAmplitude();
setState(() { setState(() {
_duration += Duration(seconds: 1); _duration += Duration(milliseconds: 100);
}); });
}); });
} catch (e, s) { } catch (e, s) {
@ -71,8 +72,9 @@ class _RecordingDialogState extends State<RecordingDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const maxDecibalWidth = 64.0; const maxDecibalWidth = 64.0;
final decibalWidth = ((_amplitude.current / _amplitude.max) * 2) * final decibalWidth =
(maxDecibalWidth / 4).toDouble(); ((_amplitude == null ? 0 : _amplitude.current / _amplitude.max) * 2) *
(maxDecibalWidth / 4).toDouble();
final time = final time =
'${_duration.inMinutes.toString().padLeft(2, '0')}:${(_duration.inSeconds % 60).toString().padLeft(2, '0')}'; '${_duration.inMinutes.toString().padLeft(2, '0')}:${(_duration.inSeconds % 60).toString().padLeft(2, '0')}';
@ -86,7 +88,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
height: maxDecibalWidth, height: maxDecibalWidth,
alignment: Alignment.center, alignment: Alignment.center,
child: AnimatedContainer( child: AnimatedContainer(
duration: Duration(seconds: 1), duration: Duration(milliseconds: 100),
width: decibalWidth, width: decibalWidth,
height: decibalWidth, height: decibalWidth,
decoration: BoxDecoration( decoration: BoxDecoration(