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

time_slot 封面
插件详情v1.0.2

time_slot

一个全新的 Flutter 包,可帮助您根据给定的时间间隔或日期时间列表创建时间段,并获取时间的时段名称。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
632
喜欢数
32
Pub 分数
140

安装插件

flutter pub add time_slot

插件介绍

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

time_slot 包是专为 Flutter 设计的实用工具,旨在简化时间槽的创建和管理。它允许开发者根据指定的持续时间或自定义日期时间列表生成时间间隔。该包还提供功能,以确定给定时间对应的时段(例如上午、下午、晚上)。适用于日程安排应用、预订系统或任何需要结构化时间表示的应用程序,支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。

适合场景

  • 安排预约
  • 预订系统时间选择
  • 活动策划工具
  • 基于时间的 UI 组件
  • 每日活动追踪

主要特点

  • 从间隔或列表生成时间槽
  • 根据时间确定时段名称
  • 跨平台兼容性
  • 简单的 API 集成
  • 支持自定义时间范围
  • 轻量且快速

适合对象

  • 日历和预订应用
  • 基于时间的数据可视化
  • 面向用户的日期时间选择器
  • 移动和网页调度界面
  • 需要时间槽逻辑的开发人员

使用建议

  • 需要手动处理时区差异
  • 仅限时间段生成和时段检测
  • 无内置 UI 组件
  • 不支持重复的时间模式
  • 假设输入的时间是有效且有序的

原始 README

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

time_slot

A new Flutter package which helps in creating time slots with given time interval or list of date times and get day part name of time, and this package allow localization ar and en.

Pub Version

Demo gif

image

Installation

  1. Add this to your package's pubspec.yaml file:
dependencies:
  time_slot: any
  1. Get the package using your IDE's GUI or via command line with
$ pub get
  1. Import the time_slot.dart file in your app
import 'package:time_slot/time_slot.dart';

Features

  • Creating time slots with given time interval
  • Creating time slots with given list date times
  • Get day part name of time
  • Support for multiple selection
  • Support different display options

Usage

DayPartController image

  DayPartController dayPartController = DayPartController();

to get day part of time

  DayParts dayPart = dayPartController.getDayPartOfTime(
    time: DateTime(2023, 1, 1, 10, 30),
  ); ///  DayParts.morning

to get day part name from DayParts

  DayParts dayPart = dayPartController.getDayPartName(dayPart: dayPart),);
  /// morning

TimesSlotGridViewFromInterval

to build time slot grid view from interval (10:00 AM to 10:00 PM) every hour

image

            TimesSlotGridViewFromInterval(
                locale: "en",
                initTime: selectTime,
                crossAxisCount: 4,
                timeSlotInterval: const TimeSlotInterval(
                  start: TimeOfDay(hour: 10, minute: 00),
                  end: TimeOfDay(hour: 22, minute: 0),
                  interval: Duration(hours: 1, minutes: 0),
                ),
                onChange: (value) {
                  setState(() {
                    selectTime = value;
                  });
                },
              ),

locale = "ar",

                TimesSlotGridViewFromInterval(
                locale: "ar",
                initTime: selectTime,
                crossAxisCount: 4,
                timeSlotInterval: const TimeSlotInterval(
                  start: TimeOfDay(hour: 10, minute: 00),
                  end: TimeOfDay(hour: 22, minute: 0),
                  interval: Duration(hours: 1, minutes: 0),
                ),
                onChange: (value) {
                  setState(() {
                    selectTime = value;
                  });
                },
              ),

TimesSlotGridViewFromList

to build time slot grid view from list date.

image

            TimesSlotGridViewFromList(
                locale: "en",
                initTime: selectTime,
                crossAxisCount: 4,
                listDates: [
                  DateTime(2023, 1, 1, 10, 30),
                  DateTime(2023, 1, 1, 11, 30),
                  DateTime(2023, 1, 1, 12, 30),
                  DateTime(2023, 1, 1, 13, 30),
                  DateTime(2023, 1, 1, 14, 30),
                  DateTime(2023, 1, 1, 15, 30)
                ],
                onChange: (value) {
                  setState(() {
                    selectTime = value;
                  });
                },
              ),

locale = "ar",

                TimesSlotGridViewFromList(
                locale: "ar",
                initTime: selectTime,
                crossAxisCount: 4,
                listDates: [
                  DateTime(2023, 1, 1, 10, 30),
                  DateTime(2023, 1, 1, 11, 30),
                  DateTime(2023, 1, 1, 12, 30),
                  DateTime(2023, 1, 1, 13, 30),
                  DateTime(2023, 1, 1, 14, 30),
                  DateTime(2023, 1, 1, 15, 30)
                ],
                onChange: (value) {
                  setState(() {
                    selectTime = value;
                  });
                },
              ),

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。