パッケージ、リポジトリ、アプリカテゴリを検索

GitHub リポジトリbixat/rocket_timer

rocket_timer

rocket_timer パッケージは、開始、一時停止、停止、リセット、カウントダウンモードと通常モードの切り替えをサポートしています

rocket_timer のプロジェクト画像
スター
0
フォーク
1
最終プッシュ(UTC)
2023/10/01
プロジェクト状態
公開中

元の 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.

Bixat.dev GitHub avatar
GitHub 作者

Bixat.dev ↗

Craftsmans: Where Excellence Meets Innovation.

言語DartSwiftHTMLShellObjective-CJavaKotlin

カテゴリー

使用している依存関係

依存関係一覧 3 件

  • flutter{"sdk":"flutter"}
  • flutter_test開発用{"sdk":"flutter"}
  • flutter_lints開発用^2.0.0

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗