Reputation: 294
I have a Linear Percent Indicator and in that there is a percent and an animationDuration, the animation Duration is set to whatever timer the api returns * 1000 since animation Duration accepts miliseconds, in my function i need that if the user gets the answer right within a spicific time for example if the api returns as time 60 secs, if the user gets the answer right from 1 second until 20 secs then he gets 3 stars rating, from 21 to 40 secs 2 stars rating, and from 41 to 60 and the answer right he gets 1 star rating. For now in the function the only condition in there is if the user gets the answer right or wrong, i need to be a timer in there depending on how long the user finishes the question and depending on the right or wrong answer he chooses thats where he gets the rating so depending on time and right or wrong answer.
child: Container(
height: 30,
child: RotatedBox(
quarterTurns: -2,
child: LinearPercentIndicator( // the linearPercentIndicator
animation: true,
width: 320.0,
lineHeight: 12.0,
percent: 1.0,
animationDuration: data[widget.CurrentIndex].timer * 1000,
backgroundColor: Colors.pink.shade200,
progressColor: Colors.pink.shade400,
),
),
),
String joinedWords =
selectedWords.join(" ").toString();
String _setRatingInAlert() { // the function witch i want to
use the animation duration
if (joinedWords ==
data[widget.CurrentIndex].sentence) {
starsRating =
'assets/threestars_small.png';
} else {
starsRating =
'assets/onestar_small.png';
}
return starsRating;
}
Upvotes: 0
Views: 697
Reputation: 235
-> Use This Container
Container(
height: 30,
child: LinearPercentIndicator(
animation: true,
width: 320.0,
restartAnimation: true,
alignment: MainAxisAlignment.start,
lineHeight: 12.0,
percent: 1.0,
animationDuration:3000,
backgroundColor: Colors.red,
progressColor: Colors.black38,
),
),
Upvotes: 1