搜索插件、代码仓与 APP 分类

插件详情v5.1.1

flutter_timezone

一个用于获取设备本地时区的 Flutter 插件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
138万
喜欢数
344
Pub 分数
160

安装插件

flutter pub add flutter_timezone

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

flutter_timezone 是一个 Flutter 插件,可在多个平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上使应用程序检索设备的本地时区信息。它提供了一个简单的 API 来访问当前时区,从而更轻松地以本地化方式处理时间相关操作。该包对于需要精确时区感知功能的应用程序尤其有用,例如日程安排、日历应用或显示本地时间。该插件利用原生平台 API 以确保结果可靠。

适合场景

  • 以用户友好的格式显示本地时间
  • 基于用户时区的调度事件
  • 构建日历或提醒应用程序
  • 处理全球应用中的时区转换
  • 确保多区域应用程序中的时间戳准确

主要特点

  • 跨平台时区检测
  • 简单且一致的 API
  • 支持所有主要的Flutter平台
  • 依赖于原生设备的时区设置
  • 轻量且易于集成

适合对象

  • 需要准确处理本地时间的应用程序
  • 面向不同地区用户的全球应用
  • 时间敏感的应用程序,如日历和闹钟
  • 寻求最小化设置时区逻辑的开发者
  • 需要原生时区准确性的项目

使用建议

  • 在某些系统上需要适当的平台权限
  • 如果设备时区在运行时发生更改,可能不会动态更新
  • 仅限读取时区;不支持设置
  • 取决于设备级别的时区配置
  • 不适合超出检索范围的复杂时区计算

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flutter_timezone

pub package Keep a Changelog v1.1.0

A flutter plugin for getting the local timezone of the OS.

This is a fork of the original flutter_native_timezone due to lack of maintenance of that package.

Getting Started

Install this package and everything good will just follow along with you.

Usage examples

Get the timezone
final TimezoneInfo currentTimeZone = await FlutterTimezone.getLocalTimezone();
Localized timezone names

On supported platforms Timezone info will contain the localized timezone name. Currently, this is supported on:

  • Android
  • MacOS
  • iOS

Reference

Wikipedia's list of TZ database names

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目