搜索插件、代码仓与 APP 分类

simple_timer 封面
插件详情v2.0.0

simple_timer

一个简单的计时器小部件,可显示计时器进度,并具有各种可自定义选项。

近 30 天下载
69
喜欢数
55
Pub 分数
70

安装插件

flutter pub add simple_timer

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,提供了一个简单且可自定义的计时器小部件,用于显示倒计时或秒表进度。它支持多种视觉和功能自定义,例如文本样式、颜色和动画选项。非常适合需要实时时间跟踪且设置简单的应用程序。该小部件轻量级,易于集成到现有 UI 中。它可在跨平台环境中无缝运行,无需额外配置。

适合场景

  • 健身应用中的倒计时计时器
  • 生产力工具中的计时器功能
  • 计时器在教育测验中显示
  • 游戏中的实时进度指示器
  • 基于时间的任务提醒

主要特点

  • 可自定义的计时器外观
  • 平滑的进度动画
  • 支持倒计时和秒表模式
  • 与 Flutter 小部件的轻松集成
  • 可配置的文本和颜色主题

适合对象

  • 开发时间跟踪功能的开发者
  • UI 设计师需要干净的计时器组件
  • 需要最小计时器复杂度的应用程序
  • 初学者Flutter开发者学习状态管理

使用建议

  • 仅限基本计时器功能
  • 没有内置的持续计时器持久化支持
  • 不支持多个并发计时器
  • 平台特定的行为可能有所不同
  • 需要手动处理计时器生命周期

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

SimpleTimer

A Simple Timer Widget that displays the timer progress with various customizable options.

Installing

To Start using this library include simple_timer as a dependency in your puspec.yaml file. Make sure to include the latest version.

Pub link: https://pub.dev/packages/simple_timer

Usage

To use the widget, import the package in your project

import 'package:simple_timer/simple_timer.dart';

The timer can be controlled in two ways:

  • Using a TimerController (preferred) - The TimerController is a convenience wrapper (subclass) of an AnimationController and needs a TickerProvider, so be sure to extend a TickerProvider in your class. Declare and instantiate your timer controller like below:

    // declaration
    TimerController _timerController;
    
    // instantiation
    _timerController = TimerController(this);
    

    Note: Remember to dispose the TimerController

    and set the controller property to the TimerController object like below:

    Container(
        child: SimpleTimer(
            controller: _timerController,
            duration: Duration(seconds: 10),
        )
    )
    

    TimerController methods:

    Method Description
    start Starts the timer e.g. (_timerController.start())
    pause Pauses the timer e.g. (_timerController.pause())
    reset Resets the timer e.g. (_timerController.reset())
    restart Restarts the timer e.g. (_timerController.restart())
    add Increases time left by the specified duration i.e. allows more time e.g. (_timerController.add(Duration(seconds: 10)))
    subtract Decreases time left by the specified duration i.e. reduces the time e.g. (_timerController.subtract(Duration(seconds: 10)))
  • Setting the Status - The timer can also be controler by passing a TimerStatus value to the status property; like below:

    Container(
        child: SimpleTimer(
            status: TimerStatus.start,
            duration: Duration(seconds: 10),
        )
    )
    

Note: The SimpleTimer widget uses its parent size.

Customizable Options

There are various customizable options provided by the SimpleTimer widget, see below:

Property Description Value Type Default Value
duration The duration of the timer Duration
controller A TimerController to control the timer. If this is provided then status must be null. TimerController
status An alternative to the controller that sets the status of the timer. If provided, controller must be null TimerStatus
timerStyle Sets the look of the animated timer widget TimerStyle ring
delay Sets a start delay for timer - i.e. delays the start of the timer by the specified duration Duration Duration(seconds: 0)
backgroundColor The background color of the inner shape (circle) of the timer Color grey
progressIndicatorColor The color of the animating progress indicator. Color green
progressIndicatorDirection The rotating direction of the timer's progress indicator TimerProgressIndicatorDirection clockwise
displayProgressIndicator Sets whether to show the progress indicator bool true
displayProgressText Sets whether to show the progress text bool true
progressTextStyle The TextStyle used by the progress text. TextStyle
progressTextCountDirection The counting direction of the text displayed by the timer TimerProgressTextCountDirection count_down
progressTextFormatter A callback function to format the text displayed by this Timer. String Function(Duration) displays duration in MM:SS format
onStart Callback executed when the timer starts counting VoidCallback
onEnd Callback executed when the timer has finished counting VoidCallback
valueListener The callback executed for each change in the time elapsed void Function(Duration)

Pub link: https://pub.dev/packages/simple_timer

Demo - Controlling the Timer Status

simple_timer_demo_01

Demo - Customizable options

simple_timer_demo_02

所属分类

源码仓库

使用此插件的项目

暂无相关数据。