I'm trying to create a metronome on Flutter, but the sound (using soundpool library) plays either 20 milliseconds earlier or 20 ms later. But over time the metronome never lags behind, it just sounds a little out of tune sometimes.
Timer.periodic or Stream.periodic provides the intervals, but in the second case the number of errors is only slightly less. What could be the problem?