标签: flutter-circularprogressindicator

如何使我的 CircularProgressIndicator 顺利运行(更新更平滑,而不是每秒更新,以便侧面有流动+发光?)

所以我做了一个计时器,想知道如何添加一个“发光”,使其动画/变大一点,然后回到较小的发光。另一个问题是,当我启动计时器时,它每秒都会更新(有点跳跃而不是流动)

不知道如何继续这个,因为现在尝试谷歌几个小时但没有运气。

感谢您的帮助!

这是我的代码

  var maxSeconds = 900;
  late int seconds = maxSeconds;
  Timer? timer;

  void resetTimer() {
    setState(() => seconds = maxSeconds);
    timer = null;
  }

  void startTimer({bool reset = true}) {
    if (reset) {
      resetTimer();
    }
    timer = Timer.periodic(Duration(seconds: 1), (_) {
      if (!mounted) // Putting this line of code with return under, fixed my issue i been having about mounted
        return;
      else if (seconds > 0) {
        setState(() => seconds--);
      } else {
        stopTimer(reset: false);
      }
    }); …
Run Code Online (Sandbox Code Playgroud)

animation flutter flutter-circularprogressindicator

5
推荐指数
1
解决办法
3428
查看次数

使用自定义笔画帽在 flutter 中创建自定义圆形进度指示器

我需要创建这个百分比指标在此输入图像描述

我怎样才能做到这一点?我尝试过 Flutter 中的%_indicator 包,但主要问题是我们的StrokeCap 选项数量有限。我也尝试过用两条弧线来做到这一点,但问题仍然存在。有没有一种方法可以创建自定义中风帽,或者可能有另一种没有canvas.drawArc的方法?

user-interface flutter flutter-canvas flutter-circularprogressindicator

4
推荐指数
1
解决办法
7691
查看次数

围绕计时器进度的按钮的圆形进度指示器

我有一个播放按钮,可以播放用户录制的消息。一旦用户点击播放按钮,它就会变成一个停止按钮,显示一个圆形进度指示器,该指示器根据记录的消息总时间和当前曲目时间的百分比进行进度。

我已经做了一些工作,但还不够精确,具体取决于轨道的长度(4秒与6.5秒),在循环进度指示器完成后,轨道将运行更长的时间,或者轨道将在进度指示器之前结束已经完成了。

我也希望进展顺利,而不是间歇性跳跃。 在此输入图像描述

下面是停止按钮的代码,它采用double totalTime轨道播放的总时间,然后启动计时器和动画控制器。

而且完全透明,自定义画家是我在网上找到的,但不完全理解它是如何工作的,所以即使那里没有问题,如果有人可以打破它,我将非常感激:D

import 'dart:async';
import 'dart:math';
import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';

class StopButton extends StatefulWidget {
  @override
  _StopButtonState createState() => _StopButtonState();

  final double totalTime;
  final dynamic onClickFunction;
  StopButton(this.totalTime, this.onClickFunction);
}

class _StopButtonState extends State<StopButton> with TickerProviderStateMixin {
  double percentage = 0.0;
  double newPercentage = 0.0;
  AnimationController percentageAnimationController;
  Timer timer;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    setState(() {
      percentage = 0.0;
    });
    percentageAnimationController =
        AnimationController(vsync: this, duration: Duration(milliseconds: 1000)) …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-animation flutter-circularprogressindicator

1
推荐指数
1
解决办法
2810
查看次数