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

flutter_analog_clock 封面
插件详情v1.0.3

flutter_analog_clock

一个简单且高度可定制的模拟时钟小部件。此小部件允许您自定义时钟的背景、表盘、刻度和指针。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
4070
喜欢数
68
Pub 分数
150

安装插件

flutter pub add flutter_analog_clock

插件介绍

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

一个简单且高度可定制的 Flutter 应用程序模拟时钟小部件。它允许开发者通过自定义背景、表盘设计、刻度和指针样式来调整时钟的外观。非常适合需要经典时间显示且外观精致的应用程序。该小部件支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,确保在各种设备上性能一致。代码简洁,配置选项直观,轻松集成到任何需要视觉吸引力的模拟时钟的项目中。

适合场景

  • 在仪表板应用中显示实时时间
  • 为UI添加复古或经典美学
  • 创建时间追踪或冥想应用
  • 集成到主屏幕小部件
  • 设计具有传统风格的数字钟

主要特点

  • 完全可自定义的背景和表盘
  • 可配置的手部样式和颜色
  • 对多个平台目标的支持
  • 通过 pub.dev 实现轻松集成
  • 跨屏幕尺寸的响应式设计

适合对象

  • 开发基于时间的应用程序的开发者
  • 寻求优雅时钟组件的UI设计师
  • 需要跨平台一致性的项目
  • 具有极简或复古主题的应用程序
  • 原型设计交互式时钟界面

使用建议

  • 可能需要额外的样式以兼容深色模式
  • 对高刷新率动画的性能影响
  • 有限的内置时区支持
  • 自定义可能会略微增加包大小
  • 手部动画的流畅度取决于设备性能

原始 README

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

Flutter Analog Clock

pub package

A simple, highly customizable analog clock widget. This widget enables you to customize the clock's background, dial, markings, and hands.

Install

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  flutter_analog_clock: ^1.0.3

In your library add the following import:

import 'package:flutter_analog_clock/flutter_analog_clock.dart';

Usage

1. Simple to use

  const AnalogClock()
  const AnalogClock.dark()
2. Use an image as a clock face

  Container(
    decoration: const BoxDecoration(
      image: DecorationImage(image: AssetImage('assets/dial01.webp')),
    ),
    child: const AnalogClock(
      dialColor: null,
      markingColor: null,
      hourNumberColor: null,
      secondHandColor: null,
    ),
  ),
3. With a child

  AnalogClock(
    dateTime: DateTime(2022, 10, 24, 10, 12, 07),
    isKeepTime: false,
    child: const Align(
      alignment: FractionalOffset(0.5, 0.75),
      child: Text('GMT-8'),
    ),
  ),
4. Customize to use
  AnalogClock(
    dateTime: DateTime.now(),
    isKeepTime: true,
    dialColor: Colors.white,
    dialBorderColor: Colors.black,
    dialBorderWidthFactor: 0.02,
    markingColor: Colors.black,
    markingRadiusFactor: 1.0,
    markingWidthFactor: 1.0,
    hourNumberColor: Colors.black,
    hourNumbers: const ['', '', '3', '', '', '6', '', '', '9', '', '', '12'],
    hourNumberSizeFactor: 1.0,
    hourNumberRadiusFactor: 1.0,
    hourHandColor: Colors.black,
    hourHandWidthFactor: 1.0,
    hourHandLengthFactor: 1.0,
    minuteHandColor: Colors.black,
    minuteHandWidthFactor: 1.0,
    minuteHandLengthFactor: 1.0,
    secondHandColor: Colors.black,
    secondHandWidthFactor: 1.0,
    secondHandLengthFactor: 1.0,
    centerPointColor: Colors.black,
    centerPointWidthFactor: 1.0,
  )
5. Specify a time
class ExampleSpecifyTime extends StatefulWidget {
  const ExampleSpecifyTime({Key? key}) : super(key: key);

  @override
  State<ExampleSpecifyTime> createState() => _ExampleSpecifyTimeState();
}

class _ExampleSpecifyTimeState extends State<ExampleSpecifyTime> {
  final GlobalKey<AnalogClockState> _analogClockKey = GlobalKey();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Analog clock'),
      ),
      body: AnalogClock(
        key: _analogClockKey,
        dateTime: DateTime(2022, 10, 24, 1, 23, 45),
        isKeepTime: false,
      ),
      persistentFooterButtons: [
        ElevatedButton(
          onPressed: () {
            _analogClockKey.currentState!.dateTime = DateTime.now();
          },
          child: const Text('Now'),
        ),
        ElevatedButton(
          onPressed: () {
            _analogClockKey.currentState!.isKeepTime = true;
          },
          child: const Text('Keep time'),
        ),
      ],
    );
  }
}

You can find all custom options here:

https://github.com/conghaonet/flutter_analog_clock/blob/master/example/lib/example.dart

所属分类

源码仓库

使用此插件的项目

暂无相关数据。