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

time_range_picker 封面
插件详情v2.3.1

time_range_picker

一个用于 Flutter 的时间范围选择器。此小部件允许您打开一个对话框,以选择包含开始时间和结束时间的时间段。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
6040
喜欢数
186
Pub 分数
140

安装插件

flutter pub add time_range_picker

插件介绍

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

一个 Flutter 包,提供可自定义的时间范围选择器小部件,通过直观的对话框界面,使用户能够在指定时间范围内选择开始时间和结束时间。专为跨平台使用而设计,支持 Android、iOS、Web、macOS、Windows 和 Linux。该选择器非常适合用于日程安排、预订或任何需要精确时间间隔选择的应用程序。它可无缝集成到现有的 Flutter 应用中,并提供简洁、响应式的用户界面。

适合场景

  • 安排预约
  • 预订时间槽
  • 设置定时器
  • 配置事件持续时间
  • 跟踪工作时间

主要特点

  • 基于对话框的时间选择
  • 开始和结束时间选择器
  • 跨平台兼容性
  • 可自定义的 UI
  • 响应式设计

适合对象

  • 日历和日程安排应用
  • 时间跟踪工具
  • 预订系统
  • 事件管理平台
  • 生产力应用

使用建议

  • 需要 Flutter SDK 2.0 或更高版本
  • 时间步长间隔的自定义有限
  • 不支持重叠时间的内置验证
  • 可能需要额外的样式以支持深色模式
  • 依赖外部 GitHub 仓库以获取更新

原始 README

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

Time Range Picker

A time range picker for flutter.

Getting Started

Installation

Add


time_range_picker : any

to your pubspec.yaml, and run

flutter packages get

in your project's root directory.

Basic Usage
import 'package:flutter/material.dart';

import 'package:time_range_picker/time_range_picker.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.blueGrey,
        body: Center(
          child: RaisedButton(
            onPressed: () async {
              TimeRange result = await showTimeRangePicker(
                context: context,
              );
              print("result " + result.toString());
            },
            child: Text("Pure"),
          ),
        ));
  }
}
Examples
Simple

Simple

Interval

Interval

Filled Style

Filled Style

Disabled Timeframe

Disabled Timeframe

Background Widget

Background Widget

Rotated Clock

Rotated Clock

Max Duration

Max Duration

Min Duration

Min Duration

Default Widget

Default Widget

Custom Dialog

Custom Dialog

Custom Dialog iOS Style

Custom Dialog iOS Style

Parameters
type param default description
TimeOfDay start TimeOfDay.now() preselected start time
TimeOfDay end now + 3h preselected end time
TimeRange disabledTime disabled time range (this time cannot be selected)
Color disabledColor Colors.red.withOpacity(0.5) the color for the disabled section
PaintingStyle paintingStyle PaintingStyle.stroke Style of the arc (filled or stroke)
Function(TimeOfDay) onStartChange
Function(TimeOfDay) onEndChange
Duration interval Duration(minutes: 5) Minimum time steps that can be selected
String fromText "From" label for start time
String toText "To" label for end time
bool use24HourFormat true use 24 hours or am / pm
double padding 36 the padding of the ring
double strokeWidth 12 the thickness of the ring
Color strokeColor primaryColor the color of the active arc from start time to end time
double handlerRadius 12 the radius of the handler to drag the arc
Color handlerColor primaryColor the color of a handler
Color selectedColor primaryColorLight the color of a selected handler
Color backgroundColor Colors.grey[200] the color of the circle outline
Widget backgroundWidget a widget displayed in the background, use e.g. an image
int ticks number of ticks displayed
double ticksOffset 0 the offset for ticks
double ticksLength strokeWidth ticks length
double ticksWidth 1 ticks thickness
Color ticksColor Colors.white Color of ticks
bool snap false Snap time bar to interval
List labels Show labels around the circle (start at 0 hours)
double labelOffset 20 Offset of the labels
bool rotateLabels true rotate labels
bool autoAdjustLabels true flip labels if the angle woulb be upside down (only if rotate labels is active)
TextStyle labelStyle Style of the labels
TextStyle timeTextStyle TextStyle of the time texts
TextStyle activeTimeTextStyle TextStyle of the currently moving time text
bool hideTimes false hide the time texts
double clockRotation 0 rotate the clock around angle
Duration maxDuration null maximum Duration that can be picked
Duration minDuration Duration(minutes: 30) minimum Duration that can be picked
bool barrierDismissible true barrierDismissible false = user must tap button to close time range picker

所属分类

源码仓库

使用此插件的项目