date_picker_number 1.0.2

Flutter: Date Picker Number #

Easy in use date picker supported by numerical keyboard.

gif_1.gif gif_2.gif

Getting started #

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

dependencies:
  ...
  date_picker_number: "^1.0.2"

In your library add the following import:

import 'package:date_picker_number/date_picker_number.dart';
import 'package:date_picker_number/date_picker_number_Settings.dart';

For help getting started with Flutter, view the online documentation.

Usage #

import 'package:flutter/material.dart';
import 'package:date_picker_number/date_picker_number.dart';
import 'package:date_picker_number/date_picker_number_Settings.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: DatePickerNumber(
          DatePickerNumberSettings(
            initialDay: 25,
            initialMonth: 11,
            initialYear: 2019,
            dayHeaderText: 'Day',
            monthHeaderText: 'Month',
            yearHeaderText: 'Year',
            hintDay: 'D',
            hintMonth: 'M',
            hintYear: 'Y',
            errorBorder: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.red)),
            enabledBorder: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
            disabledBorder: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.black)),
            focusedBorder: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.black)),
            focusedErrorBorder: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.red)),
            errorTextStyle: const TextStyle(color: Colors.red),
            headerTextStyle: const TextStyle(color: Colors.grey),
            inputStyle: const TextStyle(color: Colors.black),
            hintStyle: const TextStyle(color: Colors.grey),
            inputFieldPadding: const EdgeInsets.all(5),
            inputFieldWidth: 22,
          ),
          (day) {
            return day > 0 && day < 32 ? null : 'The Day does not match a Date Format.';
          },
          (month) {
            return month > 0 && month < 13 ? null : 'The Month does not match a Date Format.';
          },
          (year) {
            return year > 1900 && year < 2019 ? null : 'The year does not match a Date Format.';
          },
          (day, month, year) {
            DateTime dateTime = DateTime.utc(year, month, day);
            print('generated date time $dateTime');
          }
        ),
      ),
    );
  }
}

Changelog #

Please see the Changelog page to know what's recently changed.

License #

Copyright 2019 Marcin Butanowicz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[1.0.2] - Adjustments.

  • Validated boolean value on date callback.

[1.0.1] - Hint text.

  • Applied a hint text to input fields.

[1.0.0] - Initial release.

  • Initial release.

example/README.md

test_widget #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

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

Use this package as a library

1. Depend on it

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


dependencies:
  date_picker_number: ^1.0.2

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:date_picker_number/date_picker_number.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
40
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]
70
Learn more about scoring.

We analyzed this package on Sep 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/date_picker_number.dart.

Run flutter format to format lib/date_picker_number.dart.

Format lib/date_picker_number_settings.dart.

Run flutter format to format lib/date_picker_number_settings.dart.

Format lib/input_field_widget.dart.

Run flutter format to format lib/input_field_widget.dart.

Format lib/input_model.dart.

Run flutter format to format lib/input_model.dart.

Format lib/input_section_widget.dart.

Run flutter format to format lib/input_section_widget.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8