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

插件详情v0.0.3

flutter_time_range

一个完全可定制的 Flutter 小部件,允许用户选择时间段(从 - 到)

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
45
喜欢数
24
Pub 分数
140

安装插件

flutter pub add flutter_time_range

插件介绍

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

一个完全可自定义的 Flutter 小部件,旨在让用户选择一个时间范围,从开始时间到结束时间。它支持直观的时间选择,并在多个平台上提供流畅的用户界面交互。该小部件非常适合用于日程安排、预订或任何需要时间间隔输入的应用程序。设计时注重灵活性,允许开发者自定义外观、行为和验证规则。兼容 Android、iOS、Web、macOS、Windows 和 Linux,适用于跨平台应用程序。

适合场景

  • 安排预约
  • 预订系统
  • 活动策划
  • 时间跟踪工具
  • 自定义时间输入表单

主要特点

  • 可自定义的时间范围选择器
  • 支持多个平台
  • 可配置的开始/结束时间限制
  • 流畅的用户界面交互
  • 可扩展的样式选项
  • 内置验证

适合对象

  • 跨平台应用
  • 预约预订功能
  • 基于时间的数据输入
  • 需要灵活时间输入的开发者
  • UI密集型的日程安排界面

使用建议

  • 需要手动处理时间逻辑
  • 有限的内置时区支持
  • 可能需要对边缘情况额外验证
  • 未针对非常大的时间范围进行优化

原始 README

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

flutter_time_range Build Status

A fully customizable flutter widget that allowing users to choose time range (from - to)

Showcase

ezgif com-gif-maker

Example

(See example for more detail)

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        navigatorKey: _navigatorKey,
        scaffoldMessengerKey: _messangerKey,
        title: 'Test Time Range Picker',
        home: Scaffold(
          appBar: AppBar(
            title: Text("Time Range Picker"),
          ),
          body: TextButton(
            child: Text("Show Dialog"),
            onPressed: () {
              showTimeRangePicker(_navigatorKey.currentState.overlay.context);
            },
          ),
        ));
  }

  // 24 Hour Format
  Future<void> showTimeRangePicker(BuildContext context) {
    return showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text("Choose event time"),
            content: TimeRangePicker(
              initialFromHour: DateTime.now().hour,
              initialFromMinutes: DateTime.now().minute,
              initialToHour: DateTime.now().hour,
              initialToMinutes: DateTime.now().minute,
              backText: "Back",
              nextText: "Next",
              cancelText: "Cancel",
              selectText: "Select",
              editable: true,
              is24Format: true,
              disableTabInteraction: true,
              iconCancel: Icon(Icons.cancel_presentation, size: 12),
              iconNext: Icon(Icons.arrow_forward, size: 12),
              iconBack: Icon(Icons.arrow_back, size: 12),
              iconSelect: Icon(Icons.check, size: 12),
              separatorStyle: TextStyle(color: Colors.grey[900], fontSize: 30),
              onSelect: (from, to) {
                _messangerKey.currentState.showSnackBar(
                    SnackBar(content: Text("From : $from, To : $to")));
                Navigator.pop(context);
              },
              onCancel: () => Navigator.pop(context),
            ),
          );
        });
  }

  // 12 Hour Format and custom style
  Future<void> showTimeRangePicker12Hour(BuildContext context) {
    return showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text("Choose event time"),
            content: TimeRangePicker(
              initialFromHour: DateTime.now().hour,
              initialFromMinutes: DateTime.now().minute,
              initialToHour: DateTime.now().hour,
              initialToMinutes: DateTime.now().minute,
              backText: "Back",
              nextText: "Next",
              cancelText: "Cancel",
              selectText: "Select",
              editable: true,
              is24Format: false,
              disableTabInteraction: true,
              iconCancel: Icon(Icons.cancel_presentation, size: 12),
              iconNext: Icon(Icons.arrow_forward, size: 12),
              iconBack: Icon(Icons.arrow_back, size: 12),
              iconSelect: Icon(Icons.check, size: 12),
              inactiveBgColor: Colors.grey[800],
              timeContainerStyle: BoxDecoration(
                  color: Colors.grey[800],
                  borderRadius: BorderRadius.circular(7)),
              separatorStyle: TextStyle(color: Colors.grey[900], fontSize: 30),
              onSelect: (from, to) {
                _messangerKey.currentState.showSnackBar(
                    SnackBar(content: Text("From : $from, To : $to")));
                Navigator.pop(context);
              },
              onCancel: () => Navigator.pop(context),
            ),
          );
        });
  }

TODOS

need feedback

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。