GithubHelp home page GithubHelp logo

jesims / interval_time_picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fleximex/interval_time_picker

0.0 0.0 0.0 53 KB

A variant of the default Flutter Time Picker in which you can pick intervals.

License: MIT License

Dart 100.00%

interval_time_picker's Introduction

Interval Time Picker

pub package

This package modifies the default Flutter Time Picker widget by adding interval options when picking minutes. This means you can restrict the user from picking only certain intervals of minutes and you can choose to which interval of minutes the Time Picker will snap to in dial mode.

Update notes

  • Version 1.0.0 requires Dart SDK 2.12.0 (Flutter 2.0.0) or higher.
  • Version 2.0.0 requires Dart SDK 2.18.0 (Flutter 3.1.0) or higher.
  • Breaking change for 2.0.0: The VisibleStep enum values now start with lowercase

Usage

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

dependencies:
  ...
  interval_time_picker: ^2.0.0+5

On top of your code add the following import:

import 'package:interval_time_picker/interval_time_picker.dart';

In your code you can then call:

showIntervalTimePicker(
    context: context,
    initialTime: TimeOfDay.fromDateTime(DateTime.now()),
    interval: 5,
    visibleStep: VisibleStep.fifths,
);

Explanation

This package adds two parameters:

  • interval
  • visibleStep

In most cases it is recommended to set the Interval and VisibleStep as the same: i.e. respectively 5 and VisibleStep.fifths or 12 and VisibleStep.twelfths.

Interval

The interval parameter is the steps the Interval Time Picker uses when validating the chosen time (minutes) as well as the steps it rounds off to.
The default and minimum value is 1 minute. The maximum is 60 minutes.

It is actually possible to also use an interval that is not a factor of 60.
So i.e., if you want to use 7 you can use that as well. In that case the highest pickable minute is 56 and going higher will pick 0.

This package also fixes the issue that individual minutes are only selectable by dragging the ring:
Flutter issue #62424

VisibleStep

The visibleStep parameter is the minute labels that are visible on the ring. Choose the steps by using the VisibleStep enum.
The options are a factor of 60 with 5 being the lowest and 60 (shown as 00) being the highest. The default value is VisibleStep.fifths.

Disclaimers

  • If the initial minute is not a multiplication of the interval it will still pick that minute. So handle this yourself when calling showIntervalTimePicker.

  • For Flutter 2.0.0 until 2.10.5 use v1.1.0 of this package:
    this version modifies Flutter 2.8.0's Time Picker

  • For Flutter 3.1.0 or higher use v2.0.0 of this package:
    this version modifies Flutter 3.3.0's Time Picker

interval_time_picker's People

Contributors

axrs avatar fleximex avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.