Skip to content

Commit

Permalink
Fix leaking tickers
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodepapaya committed Sep 25, 2021
1 parent a199c2e commit e3d05a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions lib/src/widgets/flow_shader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class _FlowShaderState extends State<FlowShader>
late Animation animation2;
late Animation animation3;

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
void initState() {
super.initState();
Expand Down
16 changes: 11 additions & 5 deletions lib/src/widgets/record_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class _RecordButtonState extends State<RecordButton> {
void dispose() {
record.dispose();
timer?.cancel();
timer = null;
super.dispose();
}

Expand Down Expand Up @@ -171,16 +172,17 @@ class _RecordButtonState extends State<RecordButton> {
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);
debugPrint(filePath);
setState(() {
isLocked = false;
});
startTime = null;
recordDuration = "00:00";
timer?.cancel();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expand Down Expand Up @@ -231,9 +233,11 @@ class _RecordButtonState extends State<RecordButton> {
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);
Expand All @@ -245,9 +249,11 @@ class _RecordButtonState extends State<RecordButton> {
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!
Expand Down

0 comments on commit e3d05a7

Please sign in to comment.