패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.1

smart_countdown

특정 종료 일시까지 사용자 정의 가능한 카운트다운 타이머로, 초당 새로 고침됩니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
28
좋아요
5
Pub 점수
150

패키지 설치

flutter pub add smart_countdown

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

SmartCountdown은 지정된 종료 DateTime까지 매초 업데이트되는 사용자 정의 가능한 카운트다운 타이머를 제공하는 Flutter 패키지입니다. 간단함과 유연성을 고려하여 설계되어 개발자가 앱에 동적 카운트다운을 쉽게 통합할 수 있도록 합니다. Android, iOS, Web, macOS, Windows, Linux 등 다양한 플랫폼을 지원하여 크로스플랫폼 애플리케이션에 적합합니다. 깔끔한 API 설계와 최소한의 설정으로 실시간 카운트다운 표시를 가능하게 하며, 선택적 포맷팅 및 콜백도 지원합니다.

사용 사례

  • 이벤트 남은 시간 표시
  • 게임화 인터페이스에서 카운트다운 표시
  • 세션 지속 시간 추적
  • 제한된 시간 제안 구현
  • 이벤트 알림 만들기
  • 피트니스 또는 학습 타이머 만들기

주요 기능

  • 실시간 초단위 업데이트
  • 사용자 정의 종료 DateTime
  • 크로스 플랫폼 호환성
  • 간단하고 직관적인 API
  • 완료 시 콜백 지원
  • 유연한 형식 옵션

적합한 대상

  • 이벤트 기반 앱을 개발하는 개발자
  • 시간 제한 상호작용이 필요한 앱
  • 교육용 또는 생산성 도구
  • 게임화 기능
  • 플래시 세일이 있는 전자상거래 앱

고려 사항

  • 정확한 시스템 시계가 필요합니다
  • 일시정지/재개 기능을 지원하지 않습니다
  • 인스턴스당 하나의 카운트다운만 가능
  • 내장된 UI 컴포넌트 없음(수동으로 스타일 지정 필요)
  • 짧은 시간에서 중간 기간 타이머에 가장 적합

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Countdown Timer Plugin

A Flutter plugin to display a customizable countdown timer widget that counts down to a specific endDate. The plugin supports text customization, color options, and auto-refreshing every second.

Demo

  • MacOS

https://github.com/user-attachments/assets/c4f100c6-2d42-4f19-aa4e-f3821623769d

  • Web

https://github.com/user-attachments/assets/6c218998-ac94-44ea-8ca0-fba6576dbf22

  • IOS

https://github.com/user-attachments/assets/a96d6c35-5b32-4d4d-8671-f377beea85bc

Features

  • Displays a countdown timer.
  • Customizable styles for text and colors.
  • Option to hide zero values for days, hours, minutes, and seconds.
  • Easy-to-use widget for cross-platform support on Android, iOS, web, macOS, Linux, and Windows.

Table of Contents

Installation

Add the following line to your pubspec.yaml file under dependencies:

dependencies:
  smart_countdown: ^1.0.0

Then, run the following command:

flutter pub get
Local Development

If you're using this plugin locally (during development), add the path to the plugin:

dependencies:
  smart_countdown:
    path: ../smart_countdown

Usage

To use the plugin in your Flutter app, import the package and use the CountdownWidget widget:

import 'package:smart_countdown/smart_countdown.dart';

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    DateTime endDate = DateTime.now().add(Duration(days: 1, hours: 5));

    return Scaffold(
      appBar: AppBar(
        title: Text("Countdown Timer Example"),
      ),
      body: Center(
        child: CountdownWidget(
          endDate,
          completedText: "Countdown Complete!",
          timerStyle: TextStyle(fontSize: 18, color: Colors.blue),
          hideZeroValues: true,
        ),
      ),
    );
  }
}
CountdownWidget Parameters
Parameter Type Default Description
endDate DateTime Required The date and time the countdown will end.
completedText String? "Time Completed!" Text to display when the countdown ends.
timerStyle TextStyle? null The style to apply to the countdown text (font size, weight, etc.).
timerColor Color? Colors.grey The color of the countdown text.
hideZeroValues bool? false If true, it hides zero values (e.g., hours, minutes, etc. when they are zero).

Customization Options

  1. completedText: This parameter allows you to set custom text when the countdown is over. For example:

    completedText: "Event Started!"
    
  2. timerStyle: Customize the countdown timer's text appearance by passing a TextStyle:

    timerStyle: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.red)
    
  3. timerColor: Change the countdown timer's color using the timerColor parameter:

    timerColor: Colors.blueAccent
    
  4. hideZeroValues: If you want to hide sections of the countdown when they reach zero (e.g., hiding 00 Days), set hideZeroValues to true:

    hideZeroValues: true
    

Examples

Basic Countdown Timer
import 'package:flutter/material.dart';
import 'package:smart_countdown/smart_countdown.dart';

class CountdownPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    DateTime endDate = DateTime.now().add(Duration(days: 1, hours: 5));

    return Scaffold(
      appBar: AppBar(
        title: Text("Basic Countdown Timer"),
      ),
      body: Center(
        child: CountdownWidget(
          endDate,
        ),
      ),
    );
  }
}
Customized Countdown Timer
import 'package:flutter/material.dart';
import 'package:smart_countdown/smart_countdown.dart';

class CustomCountdownPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    DateTime endDate = DateTime.now().add(Duration(hours: 2, minutes: 45));

    return Scaffold(
      appBar: AppBar(
        title: Text("Customized Countdown Timer"),
      ),
      body:Center(
        child: CountdownWidget(
          endDate,
          completedText: "Countdown Complete!",
          timerStyle: const TextStyle(fontSize: 18, color: Colors.red),
          timerColor: Colors.red,
          hideZeroValues: true,
        ),
      ),
    );
  }
}
Countdown Timer with Days
import 'package:flutter/material.dart';
import 'package:smart_countdown/smart_countdown.dart';

class DaysCountdownPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    DateTime endDate = DateTime.now().add(Duration(days: 7));

    return Scaffold(
      appBar: AppBar(
        title: Text("Countdown Timer with Days"),
      ),
      body:Center(
        child: CountdownWidget(
          endDate,
          completedText: "Countdown Complete!",
          timerStyle: const TextStyle(fontSize: 18, color: Colors.red),
          timerColor: Colors.red,
          hideZeroValues: true,
        ),
      ),
    );
  }
}

Contributing

Contributions are welcome! Please submit a pull request if you'd like to contribute to the plugin.

Steps to Contribute:
  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/my-feature).
  3. Make your changes and commit them (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/my-feature).
  5. Open a pull request.

Feel free to submit issues or feature requests. Please make sure all code submissions adhere to the Effective Dart guidelines.

License

This plugin is licensed under the MIT License. See the LICENSE file for more details.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.