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

Parameters

typeparamdefaultdescription
TimeOfDaystartTimeOfDay.now()preselected start time
TimeOfDayendnow + 3hpreselected end time
TimeRangedisabledTimedisabled time range (this time cannot be selected)
ColordisabledColorColors.red.withOpacity(0.5)the color for the disabled section
PaintingStylepaintingStylePaintingStyle.strokeStyle of the arc (filled or stroke)
Function(TimeOfDay)onStartChange
Function(TimeOfDay)onEndChange
DurationintervalDuration(minutes: 5)Minimum time steps that can be selected
StringfromText"From"label for start time
StringtoText"To"label for end time
booluse24HourFormattrueuse 24 hours or am / pm
doublepadding26the padding of the ring
doublestrokeWidth12the thickness of the ring
ColorstrokeColorprimaryColorthe color of the active arc from start time to end time
doublehandlerRadius12the radius of the handler to drag the arc
ColorhandlerColorprimaryColorthe color of a handler
ColorselectedColorprimaryColorLightthe color of a selected handler
ColorbackgroundColorColors.grey200the color of the circle outline
WidgetbackgroundWidgeta widget displayed in the background, use e.g. an image
intticksnumber of ticks displayed
doubleticksOffset0the offset for ticks
doubleticksLengthstrokeWidthticks length
doubleticksWidth1ticks thickness
ColorticksColorColors.whiteColor of ticks
boolsnapfalseSnap time bar to interval
ListlabelsShow labels around the circle (start at 0 hours)
doublelabelOffset20Offset of the labels
boolrotateLabelstruerotate labels
boolautoAdjustLabelstrueflip labels if the angle woulb be upside down (only if rotate labels is active)
TextStylelabelStyleStyle of the labels
TextStyletimeTextStyleTextStyle of the time texts
TextStyleactiveTimeTextStyleTextStyle of the currently moving time text
boolhideTimesfalsehide the time texts

Libraries

time_range_picker