<commit_before>import 'package:flutter/material.dart';

import 'progress_circle.dart';

class CircleTimer extends StatefulWidget {
  final int validFromMs;
  final int validToMs;
  const CircleTimer(this.validFromMs, this.validToMs, {Key? key})
      : super(key: key);

  @override
  State<StatefulWidget> createState() => _CircleTimerState();
}

class _CircleTimerState extends State<CircleTimer>
    with SingleTickerProviderStateMixin {
  late AnimationController _animator;
  late Tween<double> _tween;
  late Animation<double> _progress;

  void _animate() {
    var period = widget.validToMs - widget.validFromMs;
    var now = DateTime.now().millisecondsSinceEpoch;
    _tween.begin = 1.0 - (now - widget.validFromMs) / period;
    var timeLeft = widget.validToMs - now;
    if (timeLeft > 0) {
      _animator.duration = Duration(milliseconds: timeLeft.toInt());
      _animator.forward();
    }
  }

  @override
  void initState() {
    super.initState();

    _animator = AnimationController(vsync: this);
    _tween = Tween(end: 0);
    _progress = _tween.animate(_animator)
      ..addListener(() {
        setState(() {});
      });

    _animate();
  }

  @override<commit_msg>Fix expired circle timer.<commit_after>import 'package:flutter/material.dart';

import 'progress_circle.dart';

class CircleTimer extends StatefulWidget {
  final int validFromMs;
  final int validToMs;
  const CircleTimer(this.validFromMs, this.validToMs, {Key? key})
      : super(key: key);

  @override
  State<StatefulWidget> createState() => _CircleTimerState();
}

class _CircleTimerState extends State<CircleTimer>
    with SingleTickerProviderStateMixin {
  late AnimationController _animator;
  late Tween<double> _tween;
  late Animation<double> _progress;

  void _animate() {
    var period = widget.validToMs - widget.validFromMs;
    var now = DateTime.now().millisecondsSinceEpoch;
    _tween.begin = 1.0 - (now - widget.validFromMs) / period;
    var timeLeft = widget.validToMs - now;
    if (timeLeft > 0) {
      _animator.duration = Duration(milliseconds: timeLeft.toInt());
    } else {
      _animator.duration = Duration.zero;
    }
    _animator.forward();
  }

  @override
  void initState() {
    super.initState();

    _animator = AnimationController(vsync: this);
    _tween = Tween(end: 0);
    _progress = _tween.animate(_animator)
      ..addListener(() {
        setState(() {});
      });

    _animate();
  }

  @override
{'fraction_non_alphanumeric': 0.1180073499387505, 'fraction_numerical': 0.0032666394446712946, 'mean_word_length': 3.596622889305816, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1658471', 'n_tokens_mistral': 811, 'n_tokens_neox': 776, 'n_words': 167}