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

date_time_picker 표지
패키지 상세v2.1.0

date_time_picker

날짜 또는 시계 대화 상자를 표시하기 위해 날짜 및 시간 양식 필드를 표시하는 Flutter 위젯입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
2.3만
좋아요
375
Pub 점수
130

패키지 설치

flutter pub add date_time_picker

패키지 개요

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

날짜 및 시간 입력 필드를 제공하는 플러터 위젯으로, 날짜 또는 시간 선택을 위한 대화 상자를 표시합니다. 날짜 전용 및 시간 전용 선택기 모두 지원하며, 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 개

소스 저장소

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