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

パッケージ詳細v7.0.0

date_field

適応的な Material および Cupertino 日時ピッカーを使用して DateTime 値を選択するためのフォームフィールドウィジェットです。また、ピッカーを提供するグローバル関数も用意されています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2150
いいね数
139
Pub ポイント
160

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

flutter pub add date_field

パッケージ概要

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

date_field は、プラットフォームに応じて適応するピッカー(Android および Web では Material Design、iOS では Cupertino)を備えた、DateTime 値を選択するためのフォームフィールドウィジェットを提供する Flutter パッケージです。macOS、Windows、Linux を含むすべての主要プラットフォームをサポートしています。アプリ内のどこでも簡単に日付と時刻ピッカーを呼び出すためのグローバル関数が含まれており、フォームやユーザー作業フローへの統合を簡素化します。プラットフォーム間で一貫した UX を実現しながら、ネイティブ感覚を維持しています。

用途

  • 日付選択を必要とするフォーム入力
  • タイムトラッキングアプリケーション
  • イベントスケジューリングインターフェース
  • 生年月日のあるユーザープロファイルのセットアップ
  • カレンダーに基づくデータ入力

主な機能

  • アダプティブな Material および Cupertino ピッカー
  • グローバルピッカー呼び出し関数
  • クロスプラットフォーム対応(Android、iOS、Web、macOS、Windows、Linux)
  • Form ウィジェットとの簡単な統合
  • カスタマイズ可能な日時形式

適している対象

  • 日付入力を使用してクロスプラットフォームアプリを開発する開発者
  • ネイティブ風の日付ピッカーを必要とするアプリ
  • 時間関連データを含むフォーム中心のアプリケーション
  • プラットフォーム固有のUIの一貫性を重視するチーム

注意事項

  • Flutter SDK 2.5 以上が必要です
  • 英語以外のロケールでは、追加のローカライゼーション設定が必要になる場合があります
  • 基本オプション以外のピッカー外観のカスタマイズが限られている
  • プラットフォーム固有のレンダリング動作に依存しています

元の README

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

Welcome to the Date Field package! 📅

pub package

This package provides two widgets, DateTimeField and DateTimeFormField, which allow users to pick a date and/or time from an input field. You can customize the appearance of the widgets using the decoration argument, and specify whether to ask for a date, a time, or both using the mode parameter. You can further customize the picker by configuring dialog properties.

iOS Android
Date field picker package gif on an iOS device Date field picker package gif on an Android device

Getting Started 🚀

  1. Add date_field package to your dependencies in pubspec.yaml.

    dependencies:
      ...
      date_field: ^6.0.0
    
  2. Run flutter pub get to install the package.

  3. Initialize your systems locale. If not, users might see AM/PM even when they configured their system to use 24h format. Add the following code to your main function:

    import 'package:intl/intl_standalone.dart' if (dart.library.html) 'package:intl/intl_browser.dart';
    
    Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await findSystemLocale();
      runApp(const MyApp());
    }
    
  4. Import the package in your Dart code.

    import 'package:date_field/date_field.dart';
    
  5. Use the Widget. Example:

    DateTimeFormField(
      decoration: const InputDecoration(
        labelText: 'Enter Date',
      ),
      firstDate: DateTime.now().add(const Duration(days: 10)),
      lastDate: DateTime.now().add(const Duration(days: 40)),
      initialPickerDateTime: DateTime.now().add(const Duration(days: 20)),
      onChanged: (DateTime? value) {
        selectedDate = value;
      },
    ),
    
  6. To display the adaptive dialog without the field widget, you can directly use the showAdaptiveDateTimePicker.

     final DateTime? result = await showAdaptiveDateTimePicker(
       context: context,
       mode: DateTimeFieldPickerMode.dateAndTime,
     );
    

Note that you can also use the showMaterialDateTimePicker and showCupertinoDateTimePicker functions to show the Material and Cupertino pickers directly.

Features 🎨

  • DateTimeField: A widget that allows users to pick a date and/or time from an input field.
  • DateTimeFormField: A FormField that contains a DateTimeField.
  • showAdaptiveDateTimePicker: A function that shows a date and/or time picker dialog based on the platform, with the ability to customize the dialog properties.
  • showCupertinoDateTimePicker: A function that shows a Cupertino date and/or time picker dialog.
  • showMaterialDateTimePicker: A function that shows a Material date picker dialog.

Migration to 4.0.0 🚀

Version 4.0.0 contains breaking changes. Use dart fix to migrate to the latest version.

Known Issues 🐛

  • The pickers and formatted DateTimes adjust only on iOS and Android to the Device Systems Region. On all other platforms, the pickers adjust to the locale. See 32006

License 📜

This package is released under the MIT license.

Contributing 🤝

Contributions to this package are welcome! If you find a bug or have a feature request, please create an issue on the GitHub repository. If you'd like to contribute code, please create a pull request with your changes.

Before submitting a pull request, please make sure to run the tests and ensure they all pass. Additionally, please follow the existing coding style and make sure your code is well-documented.

Thank you for your contributions!

Maintainers 👷

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

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