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

flutter_alarm_clock 封面
插件详情v0.1.2

flutter_alarm_clock

一个轻量级的 Flutter 包,用于连接 Android 时钟应用的意图。

Android
近 30 天下载
171
喜欢数
79
Pub 分数
160

安装插件

flutter pub add flutter_alarm_clock

插件介绍

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

一个轻量级的 Flutter 包,可通过意图实现与 Android 系统时钟应用的集成。它允许 Flutter 应用程序触发或与 Android 设备上的原生闹钟功能进行交互,从而在应用中实现无缝的闹钟管理。专为 Android 设计,利用平台特定功能,无需复杂的原生代码。该包非常适合需要直接访问设备闹钟系统的生产力、健康或提醒类应用程序。

适合场景

  • 通过原生闹钟安排提醒
  • 在健康应用中集成报警功能
  • 从 Flutter 应用内部触发警报
  • 构建带有闹钟支持的任务或习惯追踪应用
  • 启用基于时间的通知

主要特点

  • 基于意图的简单集成
  • 轻量且依赖极少
  • 仅限 Android 的平台支持
  • 直接访问系统警报功能
  • 无需后台服务

适合对象

  • 开发面向 Android 的提醒类应用的开发者
  • 需要原生闹钟交互的应用
  • 与系统功能的轻量级集成
  • Flutter 项目仅针对 Android 设备
  • 寻求最小化设置的警报触发器的用户

使用建议

  • 仅限 Android 平台
  • 需要 Android 系统权限
  • 依赖于设备特定时钟应用的可用性
  • 在所有 Android 版本上可能无法一致工作
  • 无 iOS 支持

原始 README

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

Android Alarm Clock Plugin for Flutter

pub package

This plugin allows Flutter apps to operate with the default clock application when the platform is Android. Provides a lightweight wrapper around clock app intents. It uses Android intents to communicate with the default clock app.

Currently supported features

  • Create new Alarms
  • Create new Timers
  • Open default Clock app showing Alarms
  • Open default Clock app showing Timers

Usage

Create an Alarm

Create a new alarm. Function arguments:
'hour' specifies alarm hour
'minutes' specifies alarm minutes
'title' specifies alarm title - optional
'skipUi' specifies whether clock app should open or not - optional

// Creates an alarm at 23:59
FlutterAlarmClock.createAlarm(hour: 23, minutes: 59);
Create a Timer

Create a new timer. Function arguments:
'length' specifies timer length in seconds
'title' specifies timer title - optional
'skipUi' specifies whether clock app should open or not - optional

// Creates a timer for 42 seconds
FlutterAlarmClock.createTimer(length: 42);
Show Alarms

Opens default clock app showing alarms.

FlutterAlarmClock.showAlarms();
Show Timers

Opens default clock app showing timers.

FlutterAlarmClock.showTimers();

Feel free to add support for additional functionality.

Note that a similar method does not currently exist for iOS.

Platform Support

Android
✔️

Example App

Screenshot
screenshot
Code
import 'package:flutter/material.dart';
import 'package:flutter_alarm_clock/flutter_alarm_clock.dart';

void main() {
  runApp(const MyApp());
}

/// {@template myApp}
/// A main class for the Flutter alarm clock example application.
/// {@endtemplate}
class MyApp extends StatefulWidget {
  /// @{@macro myApp}
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter alarm clock example'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Container(
                margin: const EdgeInsets.all(25),
                child: TextButton(
                  child: const Text(
                    'Create alarm at 23:59',
                    style: TextStyle(fontSize: 20),
                  ),
                  onPressed: () {
                    FlutterAlarmClock.createAlarm(hour: 23, minutes: 59);
                  },
                ),
              ),
              Container(
                margin: const EdgeInsets.all(25),
                child: const TextButton(
                  onPressed: FlutterAlarmClock.showAlarms,
                  child: Text(
                    'Show alarms',
                    style: TextStyle(fontSize: 20),
                  ),
                ),
              ),
              Container(
                margin: const EdgeInsets.all(25),
                child: TextButton(
                  child: const Text(
                    'Create timer for 42 seconds',
                    style: TextStyle(fontSize: 20),
                  ),
                  onPressed: () {
                    FlutterAlarmClock.createTimer(length: 42);
                  },
                ),
              ),
              Container(
                margin: const EdgeInsets.all(25),
                child: const TextButton(
                  onPressed: FlutterAlarmClock.showTimers,
                  child: Text(
                    'Show Timers',
                    style: TextStyle(fontSize: 20),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

所属分类

源码仓库

使用此插件的项目

暂无相关数据。