flutter_time_picker_spinner 1.0.6+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 96

flutter_time_picker_spinner #

Time Picker widget with spinner instead of a material time picker.

12H format
<br/>
24H format
<br/>
24H format with second
<br/>
Custom style
<br/>

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Props #

propstypesdefaultValues
timeDateTimeCurrent Time [ DateTime.now() ]
minutesIntervalint1
secondsIntervalint1
is24HourModebooltrue
isShowSecondsboolfalse
isShowSecondsboolfalse
highlightedTextStyleTextStylefalse
normalTextStyleTextStylefalse
itemHeightdouble60.0
itemWidthdouble45.0
spacingdouble20.0
alignmentAlignmentGeometryAlignment.centerRight
isForce2Digitsboolfalse
onTimeChangeTimePickerCallback

Usage #

import 'package:flutter_time_picker_spinner/flutter_time_picker_spinner.dart';

Widget widget() {
  return new TimePickerSpinner(
    is24HourMode: false,
    normalTextStyle: TextStyle(
      fontSize: 24,
      color: Colors.deepOrange
    ),
    highlightedTextStyle: TextStyle(
      fontSize: 24,
      color: Colors.yellow
    ),
    spacing: 50,
    itemHeight: 80,
    isForce2Digits: true,
    onTimeChange: (time) {
      setState(() {
        _dateTime = time;
      });
    },
  );
}

[1.0.6+1] - 2020/05/12 #

  • bug fixed because of ListView default padding

[1.0.6] - 2019/05/28 #

  • trying to fix bug on scrolling

[1.0.5] - 2019/05/28 #

  • update time initialization

[1.0.4] - 2019/05/13 #

  • Bug fixing on snap scroll

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter_time_picker_spinner/flutter_time_picker_spinner.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Time Picker Spinner Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Time Picker Spinner Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  DateTime _dateTime = DateTime.now();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: new Container(
        padding: EdgeInsets.only(
            top: 100
        ),
        child: new Column(
          children: <Widget>[
//            hourMinute12H(),
            hourMinute15Interval(),
//            hourMinuteSecond(),
//            hourMinute12HCustomStyle(),
            new Container(
              margin: EdgeInsets.symmetric(
                  vertical: 50
              ),
              child: new Text(
                _dateTime.hour.toString().padLeft(2, '0') + ':' +
                    _dateTime.minute.toString().padLeft(2, '0') + ':' +
                    _dateTime.second.toString().padLeft(2, '0'),
                style: TextStyle(
                  fontSize: 24,
                  fontWeight: FontWeight.bold
                ),
              ),
            ),
          ],
        ),
      )
    );
  }


  /// SAMPLE
  Widget hourMinute12H(){
    return new TimePickerSpinner(
      is24HourMode: false,
      onTimeChange: (time) {
        setState(() {
          _dateTime = time;
        });
      },
    );
  }
  Widget hourMinuteSecond(){
    return new TimePickerSpinner(
      isShowSeconds: true,
      onTimeChange: (time) {
        setState(() {
          _dateTime = time;
        });
      },
    );
  }
  Widget hourMinute15Interval(){
    return new TimePickerSpinner(
      spacing: 40,
      minutesInterval: 15,
      onTimeChange: (time) {
        setState(() {
          _dateTime = time;
        });
      },
    );
  }
  Widget hourMinute12HCustomStyle(){
    return new TimePickerSpinner(
      is24HourMode: false,
      normalTextStyle: TextStyle(
        fontSize: 24,
        color: Colors.deepOrange
      ),
      highlightedTextStyle: TextStyle(
        fontSize: 24,
        color: Colors.yellow
      ),
      spacing: 50,
      itemHeight: 80,
      isForce2Digits: true,
      minutesInterval: 15,
      onTimeChange: (time) {
        setState(() {
          _dateTime = time;
        });
      },
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_time_picker_spinner: ^1.0.6+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_time_picker_spinner/flutter_time_picker_spinner.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
91
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
96
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [flutter_time_picker_spinner] that is in a package requiring null.

Health suggestions

Format lib/flutter_time_picker_spinner.dart.

Run flutter format to format lib/flutter_time_picker_spinner.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test