rocket_timer
rocket_timer 套件支援啟動、暫停、停止、重設,以及在倒數計時與一般模式之間切換
- 星標
- 0
- 分支
- 1
- 最近推送(UTC)
- 2023年10月1日
- 專案狀態
- 未封存
原始 README
以下為英文專案原文快照,最新內容請造訪 GitHub。
Rocket Timer
The rocket_timer package provides a RocketTimer class for implementing countdown or normal timers in Flutter applications, as well as a RocketTimerBuilder widget for building widgets that respond to changes in a RocketTimer object. It supports starting, pausing, stopping, resetting, and switching between countdown and normal modes, and is easy to use and customize.
Usage
To use the RocketTimer class, simply create a new instance of it and call its methods to control the timer:
import 'package:rocket_timer/rocket_timer.dart';
final RocketTimer timer = RocketTimer(duration: 60, type: TimerType.countdown);
// Start the timer
timer.start();
// Pause the timer
timer.pause();
// Stop the timer
timer.stop();
// Reset the timer
timer.reset();
// Switch between countdown and normal modes
timer.switchMode();
// Restart timer
timer.restart();
To display the timer in a widget, you can use the RocketTimerBuilder widget which listens to changes in a RocketTimer object and rebuilds the widget tree accordingly:
import 'package:flutter/material.dart';
import 'package:rocket_timer/rocket_timer.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final RocketTimer _rocketTimer = RocketTimer(duration: 60, type: TimerType.countdown);
@override
void dispose() {
_rocketTimer.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: RocketTimerBuilder(
timer: _rocketTimer,
builder: (BuildContext context) {
return Text(
_rocketTimer.formattedDuration,
style: Theme.of(context).textTheme.headline1,
);
},
),
),
);
}
}
API Reference
See the full API reference for the RocketTimer class and the RocketTimerBuilder widget in the rocket_timer package documentation.
分類
使用的依賴
依賴清單 3 項
- flutter
{"sdk":"flutter"} - flutter_test開發依賴
{"sdk":"flutter"} - flutter_lints開發依賴
^2.0.0
如何選擇適合專案的儲存庫?
先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
- 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
- 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
- 使用前在 GitHub 確認 README、授權條款與 Issues。
來源與維護
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗