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

パッケージ詳細v1.0.0

age_calculator

誰かの年齢を日数、月数、年数で計算するためのFlutterパッケージ。また、2つの日付間の差を調べるにも使用できます。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.3万
いいね数
66
Pub ポイント
160

パッケージをインストール

flutter pub add age_calculator

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

age_calculator パッケージは、Flutter用のユーティリティで、人の年齢を年、月、日単位で計算するためのものです。また、2つの日付間の正確な差分を計算することも可能です。健康アプリ、登録フォーム、イベントプランナーなど、年齢検証や日付比較が必要なアプリに最適です。このパッケージは、Android、iOS、Web、macOS、Windows、Linuxといったすべての主要プラットフォームをサポートしており、クロスプラットフォームでの一貫性を確保しています。開発者がアプリに年齢計算機能をスムーズに統合できるように、シンプルで直感的なAPIを提供しています。

用途

  • ユーザー登録における年齢検証
  • 医療アプリケーションで患者の年齢を計算する
  • 年齢に基づいてイベントの参加資格を判断する
  • スケジューリング目的の日付比較
  • 日付の差分を使用してマイルストーンを追跡する

主な機能

  • 年、月、日単位での年齢を計算します
  • 日付の差を正確に計算します
  • クロスプラットフォーム互換性
  • シンプルで直感的な API
  • null安全な日付入力をサポート

適している対象

  • 年齢確認を必要とするフォーム検証
  • ヘルスケアおよびウェルネスアプリケーション
  • 誕生日と記念日トラッカー
  • 時間ベースの学習を備えた教育アプリ
  • 正確な日付演算が必要なアプリケーション

注意事項

  • 有効な DateTime 入力が必要です
  • うるう年のようなエッジケースの処理が必要になる可能性があります
  • 非常に大きな日付範囲には最適化されていません
  • 日付ベースの計算のみに限定
  • タイムゾーン対応機能を含まない

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

age_calculator

A Flutter package that allows you to perform operations between dates:

  • Calculate a person's age and the time remaining to their next birthday in years, months and days.
  • Calculate differences between two dates in years, months and days.
  • Add years, months and days to any date.

Getting Started

In your flutter project add the dependency:

dependencies: ... age_calculator: ^1.0.0

For help getting started with Flutter, view the online documentation.

Example
import 'package:age_calculator/age_calculator.dart';

void main() {
  DateTime birthday = DateTime(1997, 3, 5);

  DateDuration duration;

  // Find out your age as of today's date 2021-03-08
  duration = AgeCalculator.age(birthday);
  print('Your age is $duration'); // Your age is Years: 24, Months: 0, Days: 3

  //Find out your age on any given date
  duration = AgeCalculator.age(birthday, today: DateTime(2030, 5, 1));
  print('Your age is $duration'); // Your age is Years: 33, Months: 1, Days: 26

  // Find out when your next birthday will be at 2021-03-08
  duration = AgeCalculator.timeToNextBirthday(birthday);
  print('You next birthday will be in $duration');
  // You next birthday will be in Years: 0, Months: 11, Days: 25

  // Find out when your next birthday will be on any given date
  duration = AgeCalculator.timeToNextBirthday(birthday,
      fromDate: DateTime(2021, 3, 2));
  print('You next birthday will be in $duration');
  // You next birthday will be in Years: 0, Months: 0, Days: 3

  // Find out the difference between two dates
  duration = AgeCalculator.dateDifference(
    fromDate: DateTime(2021, 1, 2),
    toDate: DateTime(2025, 5, 2),
  );
  print('The difference is $duration');
  // You next birthday will be in Years: 4, Months: 4, Days: 0

  // Add time to any date
  DateTime date = AgeCalculator.add(
      date: DateTime(2021, 1, 2),
      duration: DateDuration(years: 5, months: 2, days: 1));
  print(date);
  // 2026-03-03 00:00:00.000
}

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト