m-amir-m / persian-datetime-picker Goto Github PK
View Code? Open in Web Editor NEWa persian (farsi) date time picker in flutter
License: BSD 3-Clause "New" or "Revised" License
a persian (farsi) date time picker in flutter
License: BSD 3-Clause "New" or "Revised" License
showRangeDatePicker method show full screen dialog in calendar initialEntryMode and in web
با سلام
اگه بشه فونت دلخواه اضافه کرد عالی میشه
مخصوصا چون اعداد انگلیسی هستن
تشکر
After updating to version 2.5.0 I have the following errors:
D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/ptime_picker.dart:813:48: Error: Property 'systemFonts' cannot be accessed on 'PaintingBinding?' because it is potentially null.
- 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/painting/binding.dart').
Try accessing using ?. instead.
}) : super(repaint: PaintingBinding.instance.systemFonts);
^^^^^^^^^^^
/D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/cupertino/cupertino_date_picker.dart:668:30: Error: Property 'systemFonts' cannot be accessed on 'PaintingBinding?' because it is potentially null.
- 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/painting/binding.dart').
Try accessing using ?. instead.
PaintingBinding.instance.systemFonts.addListener(_handleSystemFontsChange);
^^^^^^^^^^^
/D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/cupertino/cupertino_date_picker.dart:681:30: Error: Property 'systemFonts' cannot be accessed on 'PaintingBinding?' because it is potentially null.
- 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/painting/binding.dart').
Try accessing using ?. instead.
PaintingBinding.instance.systemFonts
^^^^^^^^^^^
/D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/cupertino/cupertino_date_picker.dart:1226:30: Error: Property 'systemFonts' cannot be accessed on 'PaintingBinding?' because it is potentially null.
- 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/painting/binding.dart').
Try accessing using ?. instead.
PaintingBinding.instance.systemFonts.addListener(_handleSystemFontsChange);
^^^^^^^^^^^
/D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/cupertino/cupertino_date_picker.dart:1245:30: Error: Property 'systemFonts' cannot be accessed on 'PaintingBinding?' because it is potentially null.
- 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/painting/binding.dart').
Try accessing using ?. instead.
PaintingBinding.instance.systemFonts
^^^^^^^^^^^
/D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/cupertino/cupertino_date_picker.dart:1590:31: Error: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/scheduler/binding.dart').
Try calling using ?. instead.
SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
^^^^^^^^^^^^^^^^^^^^
/D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/cupertino/cupertino_date_picker.dart:1800:30: Error: Property 'systemFonts' cannot be accessed on 'PaintingBinding?' because it is potentially null.
- 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/painting/binding.dart').
Try accessing using ?. instead.
PaintingBinding.instance.systemFonts.addListener(_handleSystemFontsChange);
^^^^^^^^^^^
/D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/cupertino/cupertino_date_picker.dart:1816:30: Error: Property 'systemFonts' cannot be accessed on 'PaintingBinding?' because it is potentially null.
- 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/painting/binding.dart').
Try accessing using ?. instead.
PaintingBinding.instance.systemFonts
^^^^^^^^^^^
/D:/flutter2.10/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/cupertino/cupertino_date_picker.dart:2063:31: Error: Method 'addPostFrameCallback' cannot be called on 'SchedulerBinding?' because it is potentially null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('/D:/flutter2.10/packages/flutter/lib/src/scheduler/binding.dart').
Try calling using ?. instead.
SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
^^^^^^^^^^^^^^^^^^^^
Here is the flutter doctor
summary:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19044.1706], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.1)
[√] IntelliJ IDEA Ultimate Edition (version 2021.3)
[√] Connected device (4 available)
[√] HTTP Host Availability
Hi.
I'm really glad that I found this project. It saved a lot of time and work for my last project. I first thank a lot for this wonderful library and kindly ask for a donation link so that I can at least appreciate your work and time in the slightest way.
Thanks again.
I just wanted to use this library to get birth dates. but after using it I understood that I can't use a year or month picker inside the date picker. Imagine that the user wants to enter it's birthdates to the app, the problem is he/she should use arrow buttons for changing month so many times. It would be awesome if when I click on year text, the year modal appears and after changing year, I can enter my birthday in.
I suggest to check out Native date picker dialog.
hello, I find a bug in the package persian_datetime_picker when using the mode: PCupertinoDatePickerMode.date
DateException: Jalali day is out of valid range.
and not show the last number of year
I try to use CupertinoTimerPicker as a Widget in my bottom sheet, but the following is thrown:
The following LateError was thrown building CupertinoTimerPicker(dirty, dependencies: [Directionality, _InheritedCupertinoTheme], state: _CupertinoTimerPickerState#816fa):
LateInitializationError: Field 'localizations' has not been initialized.
Using the default CupertinoTimerPicker provided by 'package:flutter/cupertino.dart' works just fine. I just wanted the Persian support in my app.
This is the part causing the error:
CupertinoTimerPicker( onTimerDurationChanged: (duration) {)
Hey, I think the ability of changing colors of header, buttons, background, texts and etc are needed to be supported.
hi
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/time_picker.dart:22:24: Error: 'DateUtils' is imported from both 'package:flutter/src/material/date.dart' and 'package:persian_datetime_picker/utils/date.dart'.
var dateUtiles = new DateUtils();
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/handle_picker.dart:55:29: Error: 'DateUtils' is imported from both 'package:persian_datetime_picker/utils/date.dart' and 'package:flutter/src/material/date.dart'.
initDateTime = '${DateUtils.jalaliToString(now)} # ${DateUtils.jalaliToString(now)}';
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/handle_picker.dart:55:64: Error: 'DateUtils' is imported from both 'package:persian_datetime_picker/utils/date.dart' and 'package:flutter/src/material/date.dart'.
initDateTime = '${DateUtils.jalaliToString(now)} # ${DateUtils.jalaliToString(now)}';
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/handle_picker.dart:58:29: Error: 'DateUtils' is imported from both 'package:persian_datetime_picker/utils/date.dart' and 'package:flutter/src/material/date.dart'.
initDateTime = '${DateUtils.jalaliToString(now)} 00:00';
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/handle_picker.dart:61:29: Error: 'DateUtils' is imported from both 'package:persian_datetime_picker/utils/date.dart' and 'package:flutter/src/material/date.dart'.
initDateTime = '${DateUtils.jalaliToString(now)}';
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/handle_picker.dart:334:21: Error: 'DateUtils' is imported from both 'package:persian_datetime_picker/utils/date.dart' and 'package:flutter/src/material/date.dart'.
initDate: DateUtils.jalaliToString(
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/handle_picker.dart:345:21: Error: 'DateUtils' is imported from both 'package:persian_datetime_picker/utils/date.dart' and 'package:flutter/src/material/date.dart'.
initDate: DateUtils.jalaliToString(
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/month_picker.dart:79:28: Error: 'DateUtils' is imported from both 'package:flutter/src/material/date.dart' and 'package:persian_datetime_picker/utils/date.dart'.
var dateUtiles = new DateUtils();
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/year_picker.dart:109:28: Error: 'DateUtils' is imported from both 'package:flutter/src/material/date.dart' and 'package:persian_datetime_picker/utils/date.dart'.
var dateUtiles = new DateUtils();
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/widget/day_container.dart:32:26: Error: 'DateUtils' is imported from both 'package:flutter/src/material/date.dart' and 'package:persian_datetime_picker/utils/date.dart'.
var dateUtiles = new DateUtils();
^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/widget/day_container.dart:49:28: Error: 'DateUtils' is imported from both 'package:flutter/src/material/date.dart' and 'package:persian_datetime_picker/utils/date.dart'.
var dateUtiles = new DateUtils();
^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 997
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 24s
Exception: Gradle task assembleDebug failed with exit code 1
These line (error) are showed when building
Hi, how cam I call on cancel method?
it has onConfirm but not onCancel.
سلام
آیا ویجتی هست هر 2 امکان انتخاب تاریخ و ساعت همزمان داشته باشد؟
how to change the language in english
Hi
How we can change date and time picker background and other colors ?
مقدار ساعت از ۰ تا ۲۳ هست. شما مقدار ۲۴ رو هم گذاشتید که اشتباه هست. الان هم میشه مقدار
۰:۱۰
رو انتخاب کرد و هم میشه مقدار
۲۴:۱۰
رو انتخاب کرد.
عناوین ماه نمایش داده نمیشه
Jalali? picked = await showPersianDatePicker(
context: context,
initialDate: Jalali.now(),
firstDate: Jalali(1385, 8),
lastDate: Jalali(1450, 9),
);
و بهتره که سال ها کامل نشون بده برای 1400 به بعد
Overflow from right in small phones.
calendarOnly initialEntryMode does not handle in showPersianDateRangePicker method and does not work
سلام
ببخشید من میخواستم یه سری روزهای خاص رو ببندم
مثلا بگم پنج شنبه و جمع یا مثلا یه روز خاص رو نشه انتخاب کرد
ممنون میشم راهنمایی کنید کجاشو باید تغییر بدم
تشکر
Thanks for nice lib, but using flushbar inside project causes this error!
Please use snackBar if it's possible.
How to make a time picker for 24 hours format?
سلام
وقت بخیر
متاسفانه با اپدیت فلاتر یک خطا در این پکیج ایجاد شده که ممنون میشم بررسی بشه
/C:/Users/Masder/AppData/Local/Pub/Cache/hosted/pub.dev/persian_datetime_picker-2.5.0/lib/src/pdate_picker_deprecated.dart:268:33: Error: The getter 'accentTextTheme' isn't defined for the class 'ThemeData'.
سلام وقت بخیر ممنون بابت پکیج خوبتون ولی متاسفانه نتونستم ازش استفاده کنم چون دقیق نحوه استفاده ذکر نکردید example هاش مبهم بود برای من
مثلا این یه نمونه از مثال ها بود که معلوم نیست اینو چطوری توی ui استفاده کنیم و اینکه persianFormat این ارور میده اگه امکانش هست براتون نحوه استفاده ش رو کامل تر کنید تا برای من مبتدی هم بتونم راحت ازش استفاده کنم
var picked = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
var label = picked.persianFormat(context);
سلام
من بعداز اینکه پکیج رو اضافه میکنم خطای زیر رو میگیرم و نمیتونم از پکیج استفاده کنم
`
/E:/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-2.5.0/lib/src/ptime_picker.dart:813:48: Error: Property 'systemFonts' cannot be accessed on 'PaintingBinding?' because it is potentially null.
FAILURE: Build failed with an exception.
Where:
Script 'E:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'E:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 10s
Exception: Gradle task assembleDebug failed with exit code 1
`
Hi @M-amir-M, thanks for your package. this is not a bug, it's just a suggestion for more usability and maintainability. in PersianDateTimePicker
class final type
parameter for constructor can replace with enum. this will help the user to choose a valid option.
thanks
Please add a parameter into persianFormat(context) so that we can change the time format to 24 hours.
Thanks
سلام اگر میشه امکان گرد کردن و مقدار دادن برای گرد کردن گوشه های ها رو اضافه کنید این شکلی (شکل فعلی) خیلی خشک به نظر میرسه !
@M-amir-M
Error text overflow when inputting not in range value in input entry mode of the Date Range Picker causes the error text not to be readable.
import 'package:flutter/material.dart';
import 'package:persian_datetime_picker/persian_datetime_picker.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: [
// Default Flutter Date Range Picker
Expanded(
child: Center(
child: FilledButton(
child: const Text('select date range'),
onPressed: () {
showDateRangePicker(
context: context,
firstDate: DateTime(2020),
lastDate: DateTime(2024),
initialDateRange: DateTimeRange(
start: DateTime.now(),
end: DateTime.now(),
),
initialEntryMode: DatePickerEntryMode.input,
);
},
),
),
),
// Persian Date Range Picker
Expanded(
child: Center(
child: FilledButton(
child: const Text('انتخاب بازه زمانی'),
onPressed: () {
showPersianDateRangePicker(
context: context,
initialEntryMode: PDatePickerEntryMode.input,
firstDate: Jalali(1400),
lastDate: Jalali(1403),
initialDateRange: JalaliRange(
start: Jalali.now(),
end: Jalali.now(),
),
);
},
),
),
),
],
),
);
}
}
In the lib/src/pinput_date_range_picker.dart
at lines 174
and 177
.
String? _validateDate(Jalali? date) {
if (date == null) {
return widget.errorFormatText ?? 'تاریخ انتخاب شده معتبر نمی باشد.';
} else if (date.isBefore(widget.firstDate) ||
date.isAfter(widget.lastDate)) {
return widget.errorInvalidText ?? 'تاریخ انتخاب شده معتبر نمی باشد.';
}
return null;
}
Using shorter error text such as other error texts in this widget such as تاریخ معتبر نمی باشد.
or direct translation of default flutter range picker error message in this situation (Out of range.
). My suggested translation is .خارج از محدوده
.
سلام خوبید ؟ ببخشید مزاحم شدم . در رابطه با فلاتر خواستم بگم به ورزن ۲.۸ که آپدیت کردم دیگه برنامه هایی که persian dare picker 2.3.0 استفاده کردم ارور میده
خواستم ببینم میتونید یه راهنمایی کنید ؟ یا اینکه باید آپدیت بدید؟
سلام ممنونم از پکیج خوبتون، اگر امکانش هست این قابلیت که بشه روز رو در حالت باتم شیت حذف کرد و فقط از ماه و سال استفاده کرد رو هم اضافه کنید. این ویژگی در انتخاب تاریخ برای انقضا کارت بانکی خیلی پر کاربرد است.
Please depend on shamsi_date library instead of copying it's code.
Since there are people who make issues on shamsi_date
and I think their problem is about usage of outdated shamsi_date
version. Depending on library has this advantage that when I fix some issue or add some new feature you will automatically get it. 😄 😅
If you have problems with depending on library please inform me.
Thanks.
Hi Mohammad,
Thanks for your amazing date time picker, I tried your libarary, can you support the English language?
Thanks & Regards.
plz upgrade your package for compatibility with flutter 2.8
i receive this error:
Error: Type 'WhitelistingTextInputFormatter' not found ...
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/persian_datetime_picker-1.0.7/lib/widget/dialog.dart:725:45: Error: No named parameter with the name 'shadowThemeOnly'.
final ThemeData theme = Theme.of(context, shadowThemeOnly: true);
/C:/src/flutter/packages/flutter/lib/src/material/theme.dart:119:20: Context: Found this candidate, but the arguments don't match.
static ThemeData of(BuildContext context) {
^^
موقع بیلد گرفتن این ارور رو میده
As flutter 2 and Dart null safety is released. Its time to migrate this package to null-safety.
سلام راهی هست بشه این تقویم رو سفارشی سازی کرد؟ رنگ و استایلش رو
Currently there is no pan support which means we can only click on days and are no able to drag the selected start and end dats to left and right.
در زمانی که مقدار
initialEntryMode
را برابر با
DatePickerEntryMode.calendarOnly
قرار میدهیم، ارور میدهد
It happens in every 30th day of each month (of second half of the year that the months have 30 days) when I call the following:
Jalali.now().add(days: 1)
Hello
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.