Closed s1nistr4 closed 2 months ago
void initState() { super.initState(); setState(() { DateFormat f = DateFormat("SS"); internalTime = widget.startDate; displayedTime = f.format(internalTime); }); Timer.periodic(new Duration(seconds: 1), (timer) { setState(() { DateFormat f = DateFormat("SS"); DateTime deIncrement = internalTime.subtract(new Duration(seconds: 1)); print(deIncrement); print(f.format(deIncrement)); internalTime = deIncrement; displayedTime = f.format(deIncrement); }); });
Doing this will make the format inherit the previous time and keep it the same instead of properly deincrementing it.
The pattern S denotes fractional seconds. You probably want to use s for seconds, see the docs.
S
s
Doing this will make the format inherit the previous time and keep it the same instead of properly deincrementing it.