persian_datetime_picker 0.0.1

  • Readme
  • Changelog
  • Installing
  • 68

A persian (farsi,shamsi) datetime picker for flutter, inspired by material datetime picker. #

pub package

A Flutter persian datetime picker inspired by material datetime picker and based on shamsi_date.

You can pick date / range date / time / date and time.

Usage #

Add it to your pubspec.yaml file:

dependencies:
    persian_datetime_picker: ^0.0.1

In your library add the following import:

import 'package:persian_datetime_picker/persian_datetime_picker.dart';

Here is an example how to use:

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

class MyApp extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Persian datetime picker',
      home: new MyHomePage(),
    );
  }
}

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

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

class _MyHomePageState extends State<MyHomePage> {

  void _showDateTimePicker() {
    showDialog(
      context: context,
      builder: (BuildContext _) {
        return PersianDateTimePicker(
          initial: '1398/03/20 19:50',
          type: 'datetime',
          onSelect: (date) {
            print(date);
          },
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return new Directionality(
      textDirection: TextDirection.rtl,
      child: Scaffold(
        appBar: new AppBar(
          title: new Text('Persian Datetime Picker'),
        ),
        body: new Center(
          child: Column(
            children: <Widget>[
              RaisedButton(
                onPressed: () {
                  _showDateTimePicker();
                },
                child: Text('تاریخ زمان'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

You must make dialog like below:

  void _showDateTimePicker() {
    showDialog(
      context: context,
      builder: (BuildContext _) {
        return PersianDateTimePicker(
          type: 'datetime',//optional ,default value is date.
          initial: '1398/03/20 19:50',//optional
          onSelect: (date) {
            print(date);
          },
        );
      },
    );
  }

And after that you can open dialog when call an event:

onPressed: () {
   _showDateTimePicker();
},

You have four value for type parameter .

  • datetime : when choose datetime type initial parameter must be like '1398/03/20 19:50' format.

  • date : when choose date type initial parameter must be like '1398/03/20' format.

  • rangedate : when choose rangedate type initial parameter must be like '1398/03/20 # 1398/03/20' format.

  • time : when choose time type initial parameter must be like '19:50' format.

Screenshots #

Date pickerTime pickerRange Date picker

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

Use this package as a library

1. Depend on it

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


dependencies:
  persian_datetime_picker: ^0.0.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:persian_datetime_picker/persian_datetime_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
74
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Fix lib/widget/snack_bar.dart. (-25 points)

Analysis of lib/widget/snack_bar.dart failed with 1 error:

line 22 col 7: The named parameter 'aroundPadding' isn't defined.

Fix lib/date_picker.dart. (-0.50 points)

Analysis of lib/date_picker.dart reported 1 hint:

line 115 col 11: The value of the local variable 'day' isn't used.

Fix lib/persian_datetime_picker.dart. (-0.50 points)

Analysis of lib/persian_datetime_picker.dart reported 1 hint:

line 13 col 28: Don't explicitly initialize variables to null.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/handle_picker.dart (Run flutter format to format lib/handle_picker.dart.)
  • lib/widget/partition.dart (Run flutter format to format lib/widget/partition.dart.)
  • lib/widget/render_table.dart (Run flutter format to format lib/widget/render_table.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (shamsi_date).

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and persian_datetime_picker.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flushbar ^1.5.0 1.9.0
flutter 0.0.0
shamsi_date ^0.5.5 0.5.5 0.6.3
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
Dev dependencies
flutter_test