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

date_time_picker のカバー
パッケージ詳細v2.1.0

date_time_picker

日付または時計のダイアログを表示するための日時フォームフィールドを表示するFlutterウィジェットです。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2.3万
いいね数
375
Pub ポイント
130

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

flutter pub add date_time_picker

パッケージ概要

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

日付と時刻のフォームフィールドを提供するFlutterウィジェットで、日付または時刻を選択するためのダイアログを表示します。日付のみおよび時刻のみのピッカーをサポートしており、Android、iOS、Web、macOS、Windows、Linuxで一貫したUIを提供します。このパッケージは、フォームにスムーズに統合されるように設計されており、直感的な日付と時刻の選択によりユーザー体験を向上させます。利用可能な場合はネイティブダイアログを使用し、プラットフォームに適した動作を保証します。

用途

  • 日付選択を必要とするフォーム入力
  • スケジューリングアプリでの時間入力
  • 予約システムにおける日付と時刻の入力
  • 生年月日の設定によるユーザープロファイルのセットアップ
  • 時間制限付きのイベント作成

主な機能

  • クロスプラットフォーム互換性
  • ネイティブ風のダイアログインターフェース
  • 日時モードのサポート
  • Form ウィジェットとの簡単な統合
  • カスタマイズ可能な外観と動作

適している対象

  • 日時入力が必要なモバイルおよびウェブアプリケーション
  • シンプルで信頼できる日付ピッカーを探している開発者
  • 複数プラットフォームで一貫したUXを必要とするアプリ
  • タイムセンシティブなデータを含むフォーム主体のアプリケーション

注意事項

  • 基本的なスタイル設定を超えるカスタマイズが限られている
  • 組み込みの検証ロジックなし
  • 日付の解析を手動で処理する必要があります
  • 下位プラットフォームの日付/時刻形式に依存する
  • 追加のローカリゼーション設定が必要になる場合があります

元の README

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

date_time_picker

pub package

Buy Me A Beer

A Flutter widget to show a text form field to display a date or clock dialog.
This widget extend TextField and has a similar behavior as TextFormField

Usage

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  date_time_picker: "^2.1.0"

In your library add the following import:

import 'package:date_time_picker/date_time_picker.dart';

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

Example

There are four presentations for DateTimePicker and can be defined in the type parameter:

  • DateTimePickerType.date will present a text field with the action tap showing a datePicker dialog box;
  • DateTimePickerType.time will present a text field with the action tap showing a timePicker dialog box;
  • DateTimePickerType.dateTime will present a text field with the action tap showing a datePicker dialog box then a timePicker dialog box;
  • DateTimePickerType.dateTimeSeparated will display two text fields side by side, the first for date and the second for time. Each displaying their respective dialog box, datePicker and timePicker in the tap action;
DateTimePicker(
  type: date, // options: [date | time | dateTime | dateTimeSeparated], default is date
  ...
)

initialValue or controller.text can be null, empty or a DateTime string otherwise it will throw an error.

DateTimePicker(
  initialValue: '',
  firstDate: DateTime(2000),
  lastDate: DateTime(2100),
  dateLabelText: 'Date',
  onChanged: (val) => print(val),
  validator: (val) {
    print(val);
    return null;
  },
  onSaved: (val) => print(val),
);

More complete example:

DateTimePicker(
  type: DateTimePickerType.dateTimeSeparate,
  dateMask: 'd MMM, yyyy',
  initialValue: DateTime.now().toString(),
  firstDate: DateTime(2000),
  lastDate: DateTime(2100),
  icon: Icon(Icons.event),
  dateLabelText: 'Date',
  timeLabelText: "Hour",
  selectableDayPredicate: (date) {
    // Disable weekend days to select from the calendar
    if (date.weekday == 6 || date.weekday == 7) {
      return false;
    }

    return true;
  },
  onChanged: (val) => print(val),
  validator: (val) {
    print(val);
    return null;
  },
  onSaved: (val) => print(val),
);

The result of val in onChanged, validator and onSaved will be a DateTime String or just a Time String:

  • ex.: [2020-07-20 14:30] or [15:30] DateTimePickerType.time;
  • month, day, hour and minute will be 2 digits and time always be in 24 hours mode;
  • but the presentation in text field can be formated by the dateMask parameter.

Preview

Overview

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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