diff --git a/lib/src/widgets/flow_shader.dart b/lib/src/widgets/flow_shader.dart index df0bc7a..14039d6 100644 --- a/lib/src/widgets/flow_shader.dart +++ b/lib/src/widgets/flow_shader.dart @@ -26,6 +26,12 @@ class _FlowShaderState extends State late Animation animation2; late Animation animation3; + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + @override void initState() { super.initState(); diff --git a/lib/src/widgets/record_button.dart b/lib/src/widgets/record_button.dart index 27be756..dca1707 100644 --- a/lib/src/widgets/record_button.dart +++ b/lib/src/widgets/record_button.dart @@ -77,6 +77,7 @@ class _RecordButtonState extends State { void dispose() { record.dispose(); timer?.cancel(); + timer = null; super.dispose(); } @@ -171,6 +172,10 @@ class _RecordButtonState extends State { behavior: HitTestBehavior.opaque, onTap: () async { var filePath = await Record().stop(); + timer?.cancel(); + timer = null; + startTime = null; + recordDuration = "00:00"; AudioState.files.add(filePath!); Globals.audioListKey.currentState! .insertItem(AudioState.files.length - 1); @@ -178,9 +183,6 @@ class _RecordButtonState extends State { setState(() { isLocked = false; }); - startTime = null; - recordDuration = "00:00"; - timer?.cancel(); }, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -231,9 +233,11 @@ class _RecordButtonState extends State { widget.controller.reverse(); if (isCancelled(details.localPosition)) { + timer?.cancel(); + timer = null; startTime = null; recordDuration = "00:00"; - timer?.cancel(); + debugPrint("Cancelled recording"); var filePath = await record.stop(); debugPrint(filePath); @@ -245,9 +249,11 @@ class _RecordButtonState extends State { isLocked = true; }); } else { + timer?.cancel(); + timer = null; startTime = null; recordDuration = "00:00"; - timer?.cancel(); + var filePath = await Record().stop(); AudioState.files.add(filePath!); Globals.audioListKey.currentState!