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

패키지 상세v3.7.0

timeago_flutter

Flutter용 Timeago 위젯으로 흐린 타임스탬프(예: '15분 전')를 생성합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.3만
좋아요
36
Pub 점수
150

패키지 설치

flutter pub add timeago_flutter

패키지 개요

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

사람이 읽기 쉬운 흐릿한 시간 표시(예: 15분 전, 2일 전 등)를 표시하는 플러터 패키지입니다. 상대적 시간 차이를 자동으로 계산하고 형식화함으로써 날짜 및 시간의 표시를 단순화합니다. 피드, 메시지 또는 로그에서 동적이고 사용자 친화적인 시간 레이블이 필요한 앱에 적합합니다. 여러 언어를 지원하며 모바일, 웹, 데스크톱을 포함한 모든 주요 플랫폼과 호환됩니다. 플러터의 UI 시스템과 원활하게 통합되며 최소한의 설정만 필요합니다.

사용 사례

  • 소셜 미디어 앱에서 게시물 타임스탬프 표시
  • 채팅 인터페이스에서 메시지 전송 시간 표시
  • 상대 시간으로 활동 로그 업데이트
  • 읽기 쉬운 시간 레이블을 통한 사용자 경험 향상
  • 현장 시간 형식과 실시간 데이터 동기화

주요 기능

  • 자동 상대 시간 계산
  • 다국어 지원
  • 크로스 플랫폼 호환성
  • 간단한 위젯 통합
  • 사용자 정의 시간 형식
  • 경량이고 빠름

적합한 대상

  • 소셜 미디어 애플리케이션
  • 메시징 및 채팅 앱
  • 실시간 대시보드
  • 콘텐츠 피드
  • 사용자 활동 추적

고려 사항

  • 기본이 아닌 로케일에 대해 수동 언어 설정이 필요합니다
  • 정확한 시간대를 위해 추가 구성이 필요할 수 있습니다
  • 상대적 시간 표시에 국한됨(절대 날짜는 아님)
  • 정확한 타임스탬프 기록에 적합하지 않습니다
  • 번역을 위해 하위 Dart timeago 라이브러리에 의존합니다

원본 README

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

timeago

timeago is a dart library that converts a date into a humanized text. Instead of showing a date 2020-12-12 18:30 with timeago you can display something like "now", "an hour ago", "~1y", etc

timeago pub package core library
timeago_flutter pub package flutter widgets

The easiest way to use this library via top-level function format(date):

import 'package:timeago/timeago.dart' as timeago;

main() {
    final fifteenAgo = DateTime.now().subtract(Duration(minutes: 15));

    print(timeago.format(fifteenAgo)); // 15 minutes ago
    print(timeago.format(fifteenAgo, locale: 'en_short')); // 15m
    print(timeago.format(fifteenAgo, locale: 'es')); // hace 15 minutos
}
IMPORTANT

timeago library ONLY includes en and es messages loaded by default.

To add more of the supported languages use timeago.setLocaleMessages(..). See locale messages.

Standard for language code

This library uses ISO 639-1 language code to identify the language. For more information see ISO 639-1.

Adding locales
timeago.setLocaleMessages('fr', timeago.FrMessages()); // Add french messages

print(timeago.format(fifteenAgo, locale: 'es')); // environ 15 minutes
Overriding locales or adding custom messages
// Override "en" locale messages with custom messages that are more precise and short
timeago.setLocaleMessages('en', MyCustomMessages());


// my_custom_messages.dart
class MyCustomMessages implements LookupMessages {
  @override String prefixAgo() => '';
  @override String prefixFromNow() => '';
  @override String suffixAgo() => '';
  @override String suffixFromNow() => '';
  @override String lessThanOneMinute(int seconds) => 'now';
  @override String aboutAMinute(int minutes) => '${minutes}m';
  @override String minutes(int minutes) => '${minutes}m';
  @override String aboutAnHour(int minutes) => '${minutes}m';
  @override String hours(int hours) => '${hours}h';
  @override String aDay(int hours) => '${hours}h';
  @override String days(int days) => '${days}d';
  @override String aboutAMonth(int days) => '${days}d';
  @override String months(int months) => '${months}mo';
  @override String aboutAYear(int year) => '${year}y';
  @override String years(int years) => '${years}y';
  @override String wordSeparator() => ' ';
}

Scope

While there are many request for adding more complex functionality I want keep this library as simple as possible to allow minimal maintenance.

The focus of this library should be

  1. Provide a single format function that transforms a date to a humanized value
  2. Give the abstractions for users to add their own languages or overriding them as they please
  3. Provide languages contributed by the community so users can add them as they need we should not add all languages by default.
  4. Library should not depend on any dependency

timeago_flutter widgets

  • Timeago
  • TimerRefresh
  • TimerRefreshWidget

Local development

  1. Install Melos (https://pub.dev/packages/melos):

dart pub global activate melos

  1. Bootstrap dependencies:

melos bootstrap

  1. Open desired package in VSCode or Webstorm

Live Demo

Here

카테고리

의존성

의존성 목록 1 개

소스 저장소

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