date_picker_persian 0.1.2

date_picker_persian #

date picker persian component which works on both ios and android. #

Pub

Example #

For example on how to use the component repo.

Getting started #

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

dependencies:
  ...
  date_picker_persian: "^0.1.2"

In your library add the following import:

import 'package:date_picker_persian/date_converter.dart';
import 'package:date_picker_persian/date_picker_gregorian.dart';

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

License #

Copyright 2019 Maryam Nazari

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

0.1.1 #

  • Initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:date_picker_persian/date_converter.dart';
import 'package:date_picker_persian/date_picker_gregorian.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: 'Date Picker',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Date Picker Shamsi'),
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {

  DateTime _date;
  ValueChanged<DateTime> _valueChangeDate;

  @override
  void initState() {
    super.initState();

    _date = new DateTime.now();

    _valueChangeDate = (DateTime date) {
      setState(() {
        _date = date;
      });
    };
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Container(
        child: Center(
          child: Text(getPersianDate(_date),style: TextStyle(fontSize: 18.0),),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          _selectDate(context);
        },
        tooltip: 'Increment',
        child: Icon(Icons.date_range),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

  Future<Null> _selectDate(BuildContext context) async {
    final DateTime picked = await showDatePickerShamsi(
        context: context,
        initialDate: _date,
        firstDate: new DateTime(2015, 8),
        lastDate: new DateTime(2101));
      if (picked != null && picked != _date) _valueChangeDate(picked);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  date_picker_persian: ^0.1.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_persian/date_converter.dart';
import 'package:date_picker_persian/date_picker_gregorian.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
52
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/date_picker_gregorian.dart. (-1.99 points)

Analysis of lib/date_picker_gregorian.dart reported 4 hints:

line 70 col 21: The value of the local variable 'headerTextTheme' isn't used.

line 71 col 11: The value of the local variable 'dayColor' isn't used.

line 72 col 11: The value of the local variable 'yearColor' isn't used.

line 1006 col 9: The value of the local variable 'dateShamsi' isn't used.

Format lib/date_converter.dart.

Run flutter format to format lib/date_converter.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
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

Admin