Reputation: 23
my music player is playing the first file totally fine, but when switching to the next song, it shows this error:
'package:flutter/src/material/slider.dart': Failed assertion: line 132 pos 15: 'value >= min && value <= max': is not true.
the values I'm sending to slider are not going to be negative or even null, I'm sending values this way:
Slider(
value: _duration != null
? _duration > defdur
? _position?.inMilliseconds?.toDouble() ?? 0.0
: 0.0
: 0.0,
onChanged: (double value) {
return audioPlayer.seek((value / 1000).roundToDouble());
},
min: 0.0,
max: _duration != null
? _duration > defdur
? _duration.inMilliseconds.toDouble()
: 0.0
: 0.0),
the defdur is default duration i made like this:
var defdur = Duration(milliseconds: 0);
so basically i have two inline if statements, for checking if value is null or not bigger than 1 milliseconds, return 0 and still problem occurs!
Upvotes: 1
Views: 10230
Reputation: 101
I think the minimum Max value of Flutter Sliders is 20, keep the max value 20 or greater than 20, simply add a condition if value < 20 ? 20 : value
Slider(
min: 0,
max: value.toInt() < 20 ? 20 : value,
value: _value,
onChanged: (value) {}
)
Upvotes: 1
Reputation: 89
Just Move the min
and max
properties in between the value
property and the onChanged
function will looks like the following :
value : yourValue,
min:0.0,
max: 1.0,
onChanged: (double NewValue){
//YOUR CODE
}
Upvotes: -2
Reputation: 49
Just increase 1 to the max parameter, Because, for example, some audio clips have their real time 4:00:01, and therefore this number is already greater than 4:00:00
Upvotes: 5
Reputation: 21
Try this:
return audioPlayer.seek((value / 1000).roundToDouble().round());
Upvotes: 1