persian_datepicker 1.1.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 90

Persian DatePicker #

A persian ( farsi ) datepicker for flutter.

Usage #

version 1.1.0 and above, will break functionality of older versions. It's highly recommended to update

A simple example with a TextField which turns into a datepicker

main.dart


import 'package:flutter/material.dart';
import 'package:persian_datepicker/persian_datepicker.dart';


void main() {
  runApp(Home());
}

class Home extends StatefulWidget {
  @override
  HomeState createState() {
    return new HomeState();
  }
}

class HomeState extends State<Home> {

  // our text controller
  final TextEditingController textEditingController = TextEditingController();

  PersianDatePickerWidget persianDatePicker;

  @override
  void initState() {


    /*Simple DatePicker*/
    persianDatePicker = PersianDatePicker(
      controller: textEditingController,
//      datetime: '1397/06/09',
    ).initialize();

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('دیت پیکر ساده'),),
        body: Builder(builder: (BuildContext context) {


          return Container(
            child: TextField(
              enableInteractiveSelection: false, // *** this is important to prevent user interactive selection ***
              onTap: () {
                FocusScope.of(context).requestFocus(new FocusNode()); // to prevent opening default keyboard
                showModalBottomSheet(
                    context: context,
                    builder: (BuildContext context) {
                      return persianDatePicker;
                    });
              },
              controller: textEditingController,
            ),
          );



        }),
      ),
    );
  }
}

HOW IT LOOKS #

Simple DatePicker





Range DatePicker

/*Range DatePicker*/
persianDatePicker = PersianDatePicker(
  controller: textEditingController,
  rangeDatePicker: true,
  // datetime: '1397/06/09',
  // finishDatetime: '1397/06/15',
).initialize();





Inline DatePicker

/*Inline DatePicker*/
persianDatePicker = PersianDatePicker(
  controller: textEditingController,
  datetime: '1397/06/19',
).initialize();


....


return Column(
  children: <Widget>[
    // Simple Date Picker
    Container(
      child: persianDatePicker, // just pass `persianDatePicker` variable as child with no ( )
    ),
    TextField(
      enabled: false,
      controller: textEditingController,
    ),
  ],
);





Customized DatePicker

You can customize datepicker as you wish, there are a lot of options to set, below code is just a few of them.

/*Customized DatePicker*/
persianDatePicker = PersianDatePicker(
    controller: textEditingController,
    outputFormat: 'YYYY/MM/DD',
    datetime: '1397/08/13',
    finishDatetime: '1397/08/17',
    daysBorderWidth: 3,
    weekCaptionsBackgroundColor: Colors.red,
    headerBackgroundColor: Colors.blue.withOpacity(0.5),
    headerTextStyle: TextStyle(color: Colors.blue, fontSize: 17),
    headerTodayIcon: Icon(Icons.access_alarm, size: 15,),
    datePickerHeight: 280
).initialize();




/*Customized Font Family ( Farsi Digits )*/
persianDatePicker = PersianDatePicker(
    controller: textEditingController,
    farsiDigits: true
).initialize();

Or if you have a font which supports farsi digits then you can simply pass the font name and everything would be ok اگر فونتی در برنامه استفاده کرده اید که قابلیت نمایش اعداد فارسی را دارد تنها لازم است اسم فونت را به دیت پیکر بدهید

/*Customized Font Family ( Farsi Digits )*/
persianDatePicker = PersianDatePicker(
    controller: textEditingController,
    fontFamily: 'Vazir' // here I used Vazir font
).initialize();




Important Notes نکات مهم #

up to this version all output dates are in persian.

تا این نسخه تمام تاریخ های خروجی پارسی(جلالی) هستند

rangeSeparator and your custom date separator should not be equal, otherwise datepicker will return null
مقدار ورودی rangeSeparator و جداکننده ای که برای فرمت خروجی انتخاب کرده اید نباید یکی باشند در این صورت دیت پیکر خروجی جداکننده های محدوده و خروجی مشابه هستند برمیگرداند


Persian input dates must respect YYYY/MM/DD format. output format is up to you Gregorian input dates must respect YYYY-MM-DD format. output format is persian and up to you

فرمت تاریخ های ورودی که پارسی (جلالی) هستند باید بصورت YYYY/MM/DD باشد. فرمت خروجی به دلخواه شماست

فرمت تاریخ های ورودی که میلادی هستند باید بصورت YYYY-MM-DD باشد. فرمت تاریخ خروجی، پارسی و به دلخواه شما خواهد بود


Examples #

You can find the full example in the Git Repository, example directory

[0.1.0] - 1/9/2019.

  • Persian ( Farsi ) Datepicker.

[0.1.1] - 1/9/2019.

  • Added descriptions to read me.

[0.2.0] - 1/9/2019.

  • Added comments

[0.2.1] - 1/9/2019.

  • Added example

[1.0.0] - 1/15/2019.

  • No dependency is needed
  • Inline mode is added
  • Gregorian date as input is supported
  • Bug fixes

[1.0.1] - 1/15/2019.

  • updated read me

[1.0.2] - 1/15/2019.

  • bug fix
  • updated read me

[1.0.4] - 1/15/2019.

  • some options types changed

[1.0.6] - 1/16/2019.

[1.0.7] - 1/16/2019.

  • bug fix

[1.0.9] - 1/16/2019.

[1.1.0] - 1/17/2019.

  • farsi digits support
  • font family support
  • new parameters for customization

[1.1.1] - 1/17/2019.

  • TextField farsi digits support

[1.1.2] - 1/18/2019.

  • bug fix
  • display gregorian days with the ability of changing it's location

example/example.dart

import 'package:flutter/material.dart';
import 'package:persian_datepicker/persian_datepicker.dart';

void main() {
  runApp(Home());
}

class Home extends StatefulWidget {
  @override
  HomeState createState() {
    return new HomeState();
  }
}

class HomeState extends State<Home> {
  // our text controller
  final TextEditingController textEditingController = TextEditingController();

  PersianDatePickerWidget persianDatePicker;

  @override
  void initState() {
    /*Simple DatePicker*/
    persianDatePicker = PersianDatePicker(
      controller: textEditingController,
      datetime: '1397/06/09',
    ).initialize();

    /*Range DatePicker*/
    /*persianDatePicker = PersianDatePicker(
      controller: textEditingController,
      rangeDatePicker: true,
    ).initialize();*/

    /*Gregorian DatePicker*/
    /*persianDatePicker = PersianDatePicker(
      controller: textEditingController,
      gregorianDatetime: '2018-09-08',
      outputFormat: 'YYYY/MM/DD',
    ).initialize();*/

    /*Inline DatePicker*/
    /*persianDatePicker = PersianDatePicker(
      controller: textEditingController,
      datetime: '1397/06/19',
      outputFormat: 'YYYY/MM/DD',
    ).initialize();*/

    /*Custom Format DatePicker*/
    /*persianDatePicker = PersianDatePicker(
      controller: textEditingController,
      datetime: '1397/06/19',
      outputFormat: 'MM - YYYY - DD',
    ).initialize();*/

    /*Customized DatePicker*/
    /*persianDatePicker = PersianDatePicker(
        controller: textEditingController,
        outputFormat: 'YYYY/MM/DD',
        datetime: '1397/08/13',
        finishDatetime: '1397/08/17',
        daysBorderWidth: 3,
        weekCaptionsBackgroundColor: Colors.red,
        headerBackgroundColor: Colors.blue.withOpacity(0.5),
        headerTextStyle: TextStyle(color: Colors.blue, fontSize: 17),
        headerTodayIcon: Icon(Icons.access_alarm, size: 15,),
        datePickerHeight: 280
    ).initialize();*/

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('دیت پیکر ساده'),
        ),
        body: Builder(builder: (BuildContext context) {
          return Column(
            children: <Widget>[
              // Simple Date Picker
              Container(
                child: persianDatePicker,
              ),
              TextField(
                onTap: () {
                  FocusScope.of(context).requestFocus(new FocusNode());
                },
                enableInteractiveSelection: false,
                controller: textEditingController,
              ),
            ],
          );
        }),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  persian_datepicker: ^1.1.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:persian_datepicker/persian_datepicker.dart';
  
Version Uploaded Documentation Archive
1.3.0 Mar 20, 2019 Go to the documentation of persian_datepicker 1.3.0 Download persian_datepicker 1.3.0 archive
1.2.1 Feb 8, 2019 Go to the documentation of persian_datepicker 1.2.1 Download persian_datepicker 1.2.1 archive
1.2.0 Feb 7, 2019 Go to the documentation of persian_datepicker 1.2.0 Download persian_datepicker 1.2.0 archive
1.1.7 Feb 7, 2019 Go to the documentation of persian_datepicker 1.1.7 Download persian_datepicker 1.1.7 archive
1.1.6 Jan 24, 2019 Go to the documentation of persian_datepicker 1.1.6 Download persian_datepicker 1.1.6 archive
1.1.5 Jan 21, 2019 Go to the documentation of persian_datepicker 1.1.5 Download persian_datepicker 1.1.5 archive
1.1.4 Jan 21, 2019 Go to the documentation of persian_datepicker 1.1.4 Download persian_datepicker 1.1.4 archive
1.1.3 Jan 18, 2019 Go to the documentation of persian_datepicker 1.1.3 Download persian_datepicker 1.1.3 archive
1.1.2 Jan 18, 2019 Go to the documentation of persian_datepicker 1.1.2 Download persian_datepicker 1.1.2 archive
1.1.1 Jan 17, 2019 Go to the documentation of persian_datepicker 1.1.1 Download persian_datepicker 1.1.1 archive

All 27 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
81
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]
90
Learn more about scoring.

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

  • Dart: 2.3.0
  • pana: 0.12.15
  • Flutter: 1.5.8

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

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.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test