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

패키지 상세v2.0.0

system_date_time_format

기기 시스템 설정에서 날짜 및 시간 형식 패턴을 가져오기 위한 플러그인입니다.

AndroidiOSLinuxmacOSWebWindows
30일 다운로드
3.2만
좋아요
17
Pub 점수
160

패키지 설치

flutter pub add system_date_time_format

패키지 개요

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

기기의 시스템 설정에서 날짜 및 시간 형식 패턴을 직접 가져오는 플러터 플러그인입니다. 원격 OS 구성 정보를 활용하여 다중 플랫폼 간 일관된 포맷팅을 보장하며, 지역화된 날짜 및 시간 표시가 필요한 앱에 적합합니다. 이 패키지는 Android, iOS, Linux, macOS, Web, Windows를 지원하며 수동 구성 없이 정확한 시스템 레벨 포맷팅을 제공합니다. 사용자 선호도에 자동으로 적응함으로써 로컬라이제이션 작업을 단순화합니다.

사용 사례

  • 사용자의 선호 형식으로 날짜 표시
  • 로컬라이즈된 캘린더 앱 만들기
  • 지역별 시간 표시 만들기
  • 시스템 설정과의 일관성 보장
  • 다국어 애플리케이션 지원

주요 기능

  • 기기 시스템 설정에서 형식을 가져옵니다
  • 크로스 플랫폼 호환성
  • 자동 로케일 적응
  • 수동 형식 구성이 필요하지 않습니다
  • 네이티브 OS 형식화 API를 사용합니다

적합한 대상

  • 글로벌 대상 사용자를 위한 앱
  • 현지화 중심 애플리케이션
  • 캘린더 또는 스케줄링 도구
  • 사용자 친화적인 날짜/시간 선택기
  • 시스템 일관성을 우선시하는 개발자

고려 사항

  • 일부 시스템에서는 플랫폼별 권한이 필요합니다
  • 사전 정의된 시스템 형식에 한정됨
  • 사용자 지정 형식 오버라이드를 지원하지 않을 수 있습니다
  • 기기의 지역 설정에 따라 달라짐
  • 비시스템 형식 요구 사항에 적합하지 않습니다

원본 README

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

A plugin for getting date & time format from device system settings.

Pub Package Build Status Code Coverage MIT License Android support ✓ iOS support ✓ macOS support ✓ windows support ✓ linux support ✓ web support ✓


Why system_date_time_format?

Flutter does not support retrieving date and time format patterns based on the user's system settings out of the box. However, you can use the system_date_time_format plugin to get date and time format patterns for consistent formatting in your Flutter app with ease:

final datePattern = SystemDateTimeFormat.datePattern;
print(datePattern); // e.g. "M/d/yy"
Examples
iOS (Region: United States 🇺🇸) Result
ios_setup ios_result
Android (Region: United Kingdom 🇬🇧) Result
android_setup android_result
macOS (Region: Poland 🇵🇱) Result
macos_setup macos_result
windows (Region: United States 🇺🇸) Result
windows_setup windows_result
linux (Region: United States 🇺🇸) Result
linux_setup linux_result
web (Region: Poland 🇵🇱)
web_result

Usage

Read a pattern directly from the current system settings. Medium and full date patterns return null on Windows and Linux.

import 'package:system_date_time_format/system_date_time_format.dart';

void main() {
  final date = SystemDateTimeFormat.datePattern;             // e.g. "M/d/yy"
  final mediumDate = SystemDateTimeFormat.mediumDatePattern; // e.g. "MMM d, y"
  final longDate = SystemDateTimeFormat.longDatePattern;     // e.g. "MMMM d, y"
  final fullDate = SystemDateTimeFormat.fullDatePattern;     // e.g. "EEEE, MMMM d, y"
  final time = SystemDateTimeFormat.timePattern;             // e.g. "HH:mm"
}
Migrating from 1.x

See the step-by-step migration guide.

Replace await SystemDateTimeFormat().getDatePattern() with SystemDateTimeFormat.datePattern. The other format methods follow the same naming convention. Replace calls to getAllPatterns() and SystemDateTimeFormat.of(context) with the individual getters you need. Remove the SDTFScope wrapper.

Each getter reads the current settings synchronously. A widget that reads patterns in build() picks up changes on its next rebuild.

Linux

Linux reads short date and time patterns from the active LC_TIME locale. For the long date, it uses the ICU date-only style for that locale. Install the ICU development package on the Linux build machine (for example, sudo apt install libicu-dev on Ubuntu or Debian). The application requires the matching ICU runtime libraries.

Web

Web getters use the browser’s locale and hour cycle. A getter returns null when the browser reports a field that has no matching pattern, such as a named year in the Chinese calendar. Load the JavaScript asset in index.html before Flutter starts.

From version 1.3.1 and above, the preferred way is to use the local asset:

<script src="./assets/packages/system_date_time_format/web/system_date_time_format.min.js"></script>

Alternatively, you can still use the CDN link:

<script src="https://cdn.jsdelivr.net/gh/Nikoro/system_date_time_format@main/web/system_date_time_format.min.js"></script>

index.html

<!DOCTYPE html>
<html>
<head>
    <!--...-->
    <script src="./assets/packages/system_date_time_format/web/system_date_time_format.min.js"></script>
</head>
<body>
<!--...-->
</body>
</html>
Testing

Mocktail stubs instance members. To test code that reads a static format getter, pass the consuming widget a value or a reader owned by your app. In example_with_tests, the production DeviceFormats.time getter calls SystemDateTimeFormat.timePattern. A widget test supplies a mock instance:

final formats = MockDeviceFormats();
when(() => formats.time).thenReturn('HH:mm');
await tester.pumpWidget(App(formats: formats));
expect(find.text('HH:mm'), findsOneWidget);

The example also tests how the app displays unavailable date styles. App adapter · Widget tests

카테고리

아직 데이터가 없습니다.

의존성

의존성 목록 7 개

소스 저장소

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

아직 데이터가 없습니다.

순위