mirror of
https://github.com/Iconica-Development/flutter_date_time_picker.git
synced 2025-05-18 18:33:49 +02:00
Merge remote-tracking branch 'origin/master' into feature/Improve_README
This commit is contained in:
commit
0835102dbd
13 changed files with 83 additions and 194 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -19,7 +19,7 @@ migrate_working_dir/
|
||||||
# The .vscode folder contains launch configuration and tasks you configure in
|
# The .vscode folder contains launch configuration and tasks you configure in
|
||||||
# VS Code which you may wish to be included in version control, so this line
|
# VS Code which you may wish to be included in version control, so this line
|
||||||
# is commented out by default.
|
# is commented out by default.
|
||||||
#.vscode/
|
.vscode/
|
||||||
|
|
||||||
# Flutter/Dart/Pub related
|
# Flutter/Dart/Pub related
|
||||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||||
|
@ -28,3 +28,11 @@ migrate_working_dir/
|
||||||
.dart_tool/
|
.dart_tool/
|
||||||
.packages
|
.packages
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
|
||||||
|
example/web
|
||||||
|
example/android
|
||||||
|
example/ios
|
||||||
|
example/macos
|
||||||
|
example/windows
|
||||||
|
example/linux
|
|
@ -1,3 +1,10 @@
|
||||||
|
## 2.1.0
|
||||||
|
* Fixed internalization of the package
|
||||||
|
* Added dragcallback to the draggablesheet
|
||||||
|
|
||||||
|
## 2.0.0
|
||||||
|
* Added overlay variant of datetimepicker
|
||||||
|
|
||||||
## 1.2.0
|
## 1.2.0
|
||||||
* Made date time picker height customizable
|
* Made date time picker height customizable
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# This file should be version controlled.
|
# This file should be version controlled.
|
||||||
|
|
||||||
version:
|
version:
|
||||||
revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
|
||||||
channel: stable
|
channel: stable
|
||||||
|
|
||||||
project_type: app
|
project_type: app
|
||||||
|
@ -13,26 +13,11 @@ project_type: app
|
||||||
migration:
|
migration:
|
||||||
platforms:
|
platforms:
|
||||||
- platform: root
|
- platform: root
|
||||||
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
|
||||||
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
|
||||||
- platform: android
|
|
||||||
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
- platform: ios
|
|
||||||
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
- platform: linux
|
|
||||||
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
- platform: macos
|
|
||||||
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
- platform: web
|
- platform: web
|
||||||
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
|
||||||
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
|
||||||
- platform: windows
|
|
||||||
create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543
|
|
||||||
|
|
||||||
# User provided section
|
# User provided section
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import 'package:datetime_picker_example/shaped_border.dart';
|
import 'package:datetime_picker_example/shaped_border.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_date_time_picker/flutter_date_time_picker.dart';
|
import 'package:flutter_date_time_picker/flutter_date_time_picker.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
|
@ -17,6 +18,17 @@ class MyApp extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
// set locale to dutch
|
||||||
|
localizationsDelegates: const [
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
],
|
||||||
|
locale: const Locale('nl', 'NL'),
|
||||||
|
supportedLocales: const [
|
||||||
|
Locale('nl', 'NL'),
|
||||||
|
Locale('en', 'US'),
|
||||||
|
],
|
||||||
title: 'Demo drag down date time picker',
|
title: 'Demo drag down date time picker',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
|
@ -28,8 +40,10 @@ class MyApp extends StatelessWidget {
|
||||||
|
|
||||||
class DatePickerDemo extends StatelessWidget {
|
class DatePickerDemo extends StatelessWidget {
|
||||||
const DatePickerDemo({Key? key}) : super(key: key);
|
const DatePickerDemo({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// set locale to Dutch
|
||||||
const dateTimePickerTheme = DateTimePickerTheme(
|
const dateTimePickerTheme = DateTimePickerTheme(
|
||||||
dateBoxShape: DateBoxShape.roundedRectangle,
|
dateBoxShape: DateBoxShape.roundedRectangle,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
|
@ -120,6 +134,8 @@ class DatePickerDemo extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
DragDownDateTimePicker(
|
DragDownDateTimePicker(
|
||||||
|
onTimerPickerSheetChange: (value) {},
|
||||||
|
alwaysUse24HourFormat: true,
|
||||||
dateTimePickerTheme: const DateTimePickerTheme(
|
dateTimePickerTheme: const DateTimePickerTheme(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
markedIndicatorColor: Colors.red,
|
markedIndicatorColor: Colors.red,
|
||||||
|
@ -145,7 +161,7 @@ class DatePickerDemo extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
markedDates: [DateTime(2022, 9, 6)],
|
markedDates: [DateTime(2022, 9, 6)],
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -61,7 +61,7 @@ packages:
|
||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "2.0.0"
|
version: "2.1.0"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
@ -69,13 +69,18 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
|
flutter_localizations:
|
||||||
|
dependency: "direct main"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
intl:
|
intl:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: intl
|
name: intl
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: datetime_picker_example
|
name: datetime_picker_example
|
||||||
description: DateTimePicker Widget
|
description: DateTimePicker Widget
|
||||||
|
|
||||||
publish_to: 'none'
|
publish_to: "none"
|
||||||
|
|
||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
|
@ -12,13 +12,15 @@ dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
flutter_date_time_picker:
|
flutter_date_time_picker:
|
||||||
path: ../
|
path: ../
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
intl: ^0.17.0 # Add this line
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^2.0.0
|
flutter_lints: ^2.0.0
|
||||||
flutter:
|
flutter:
|
||||||
|
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_date_time_picker/src/models/date_time_picker_theme.dart';
|
import 'package:flutter_date_time_picker/src/models/date_time_picker_theme.dart';
|
||||||
import 'package:flutter_date_time_picker/src/utils/date_time_picker_controller.dart';
|
import 'package:flutter_date_time_picker/src/utils/date_time_picker_controller.dart';
|
||||||
|
@ -15,110 +13,15 @@ class DragDownDateTimePicker extends StatefulWidget {
|
||||||
/// A widget that displays a date picker from a sheet form the top of the screen.
|
/// A widget that displays a date picker from a sheet form the top of the screen.
|
||||||
/// This sheet displays initially displays a week but can be dragged down to show a full month.
|
/// This sheet displays initially displays a week but can be dragged down to show a full month.
|
||||||
/// Both views can be dragged sideways to show the next or previous week/month.
|
/// Both views can be dragged sideways to show the next or previous week/month.
|
||||||
///
|
|
||||||
/// Example:
|
const DragDownDateTimePicker({
|
||||||
/// ```dart
|
|
||||||
/// DatePicker(
|
|
||||||
/// dateTimePickerTheme: const DateTimePickerTheme()
|
|
||||||
/// initialDate: selectedDate,
|
|
||||||
/// highlightToday: true,
|
|
||||||
/// onTapDay: (date) {
|
|
||||||
/// setState(() {
|
|
||||||
/// selectedDate = date;
|
|
||||||
/// });
|
|
||||||
/// },
|
|
||||||
/// markedDates: [
|
|
||||||
/// DateTime(2022, 3, 14),
|
|
||||||
/// ],
|
|
||||||
/// wrongTimeDialog:
|
|
||||||
/// AlertDialog(
|
|
||||||
/// title: const Text('Invalid Time'),
|
|
||||||
/// content: SingleChildScrollView(
|
|
||||||
/// child: ListBody(
|
|
||||||
/// children: const <Widget>[
|
|
||||||
/// Text(
|
|
||||||
/// 'The time you try to choose is disabled, try to pick another time.'),
|
|
||||||
/// ],
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// actions: <Widget>[
|
|
||||||
/// TextButton(
|
|
||||||
/// child: const Text('OK'),
|
|
||||||
/// onPressed: () {
|
|
||||||
/// Navigator.pop(context);
|
|
||||||
/// },
|
|
||||||
/// ),
|
|
||||||
/// ],
|
|
||||||
/// ),
|
|
||||||
/// header: Container(
|
|
||||||
/// height: 100,
|
|
||||||
/// width: MediaQuery.of(context).size.width,
|
|
||||||
/// padding: const EdgeInsets.only(bottom: 10),
|
|
||||||
/// child: Row(
|
|
||||||
/// crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
/// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
/// children: [
|
|
||||||
/// const SizedBox(
|
|
||||||
/// width: 160,
|
|
||||||
/// height: 34,
|
|
||||||
/// child: Center(
|
|
||||||
/// child: Text(
|
|
||||||
/// 'Personal calendar',
|
|
||||||
/// style: TextStyle(
|
|
||||||
/// fontSize: 16,
|
|
||||||
/// fontWeight: FontWeight.w900,
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// const SizedBox(
|
|
||||||
/// width: 4,
|
|
||||||
/// ),
|
|
||||||
/// Container(
|
|
||||||
/// width: 160,
|
|
||||||
/// height: 34,
|
|
||||||
/// decoration: BoxDecoration(
|
|
||||||
/// color: const Color(0xFF00273D),
|
|
||||||
/// borderRadius: const BorderRadius.all(
|
|
||||||
/// Radius.circular(10),
|
|
||||||
/// ),
|
|
||||||
/// boxShadow: [
|
|
||||||
/// BoxShadow(
|
|
||||||
/// color: const Color(0xFF000000).withOpacity(0.50),
|
|
||||||
/// offset: const Offset(0, 6),
|
|
||||||
/// blurRadius: 9,
|
|
||||||
/// ),
|
|
||||||
/// ],
|
|
||||||
/// ),
|
|
||||||
/// child: const Center(
|
|
||||||
/// child: Text(
|
|
||||||
/// 'Work calendar',
|
|
||||||
/// style: TextStyle(
|
|
||||||
/// color: Colors.white,
|
|
||||||
/// fontSize: 16,
|
|
||||||
/// fontWeight: FontWeight.w900,
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// ],
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
/// child: Container(
|
|
||||||
/// margin: const EdgeInsets.only(
|
|
||||||
/// top: 195,
|
|
||||||
/// ),
|
|
||||||
/// child: HolidayRoster(),
|
|
||||||
/// ),
|
|
||||||
/// ),
|
|
||||||
///```
|
|
||||||
DragDownDateTimePicker({
|
|
||||||
this.dateTimePickerTheme = const DateTimePickerTheme(),
|
this.dateTimePickerTheme = const DateTimePickerTheme(),
|
||||||
this.header,
|
this.header,
|
||||||
|
this.onTimerPickerSheetChange,
|
||||||
this.onTapDay,
|
this.onTapDay,
|
||||||
this.highlightToday = true,
|
this.highlightToday = true,
|
||||||
this.wrongTimeDialog,
|
this.wrongTimeDialog,
|
||||||
bool? use24HourFormat,
|
this.alwaysUse24HourFormat,
|
||||||
this.pickTime = false,
|
this.pickTime = false,
|
||||||
this.initialDate,
|
this.initialDate,
|
||||||
this.markedDates,
|
this.markedDates,
|
||||||
|
@ -126,9 +29,7 @@ class DragDownDateTimePicker extends StatefulWidget {
|
||||||
this.disabledTimes,
|
this.disabledTimes,
|
||||||
this.child,
|
this.child,
|
||||||
super.key,
|
super.key,
|
||||||
}) {
|
});
|
||||||
alwaysUse24HourFormat = use24HourFormat ?? _useTimeFormatBasedOnLocale();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The child contained by the DatePicker.
|
/// The child contained by the DatePicker.
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
|
@ -149,8 +50,8 @@ class DragDownDateTimePicker extends StatefulWidget {
|
||||||
final bool highlightToday;
|
final bool highlightToday;
|
||||||
|
|
||||||
/// a [bool] to set de clock on [TimePickerDialog] to a fixed 24 or 12-hour format.
|
/// a [bool] to set de clock on [TimePickerDialog] to a fixed 24 or 12-hour format.
|
||||||
/// By default this gets determined by the [Locale] on the device.
|
/// By default this gets determined by the settings on the user device.
|
||||||
late final bool alwaysUse24HourFormat;
|
final bool? alwaysUse24HourFormat;
|
||||||
|
|
||||||
/// [pickTime] is a [bool] that determines if the user is able to pick a time after picking a date using the [TimePickerDialog].
|
/// [pickTime] is a [bool] that determines if the user is able to pick a time after picking a date using the [TimePickerDialog].
|
||||||
final bool pickTime;
|
final bool pickTime;
|
||||||
|
@ -167,6 +68,10 @@ class DragDownDateTimePicker extends StatefulWidget {
|
||||||
/// a [List] of [TimeOfDay] objects that cannot be picked in the [TimePickerDialog].
|
/// a [List] of [TimeOfDay] objects that cannot be picked in the [TimePickerDialog].
|
||||||
final List<TimeOfDay>? disabledTimes;
|
final List<TimeOfDay>? disabledTimes;
|
||||||
|
|
||||||
|
/// Function that gets called when the view changes from week to month or vice versa.
|
||||||
|
/// The value is the amount of scrolledpixels.
|
||||||
|
final Function(double)? onTimerPickerSheetChange;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _DragDownDateTimePickerState();
|
State<StatefulWidget> createState() => _DragDownDateTimePickerState();
|
||||||
}
|
}
|
||||||
|
@ -199,6 +104,9 @@ class _DragDownDateTimePickerState extends State<DragDownDateTimePicker> {
|
||||||
_dateTimePickerController.addListener(() {
|
_dateTimePickerController.addListener(() {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
|
_dragController.addListener(() {
|
||||||
|
widget.onTimerPickerSheetChange?.call(_dragController.pixels);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -279,24 +187,3 @@ class _DragDownDateTimePickerState extends State<DragDownDateTimePicker> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _useTimeFormatBasedOnLocale() {
|
|
||||||
// Get LocaleName of current platform and split language- and countryCode in 2 List values.
|
|
||||||
List<String> deviceLocale = Platform.localeName.split('_');
|
|
||||||
|
|
||||||
// Make LocaleName of current platform in a Locale Object
|
|
||||||
Locale defaultLocale = Locale.fromSubtags(
|
|
||||||
languageCode: deviceLocale[0],
|
|
||||||
countryCode: deviceLocale[1],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Determine Country.
|
|
||||||
switch (defaultLocale.countryCode) {
|
|
||||||
case 'NL':
|
|
||||||
return true;
|
|
||||||
case 'US':
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,31 +31,9 @@ extension DateTimeExtension on DateTime {
|
||||||
bool get isLeapYear =>
|
bool get isLeapYear =>
|
||||||
(year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0);
|
(year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0);
|
||||||
|
|
||||||
|
|
||||||
/// Returns the amount of days in the current month of the [DateTime] object
|
/// Returns the amount of days in the current month of the [DateTime] object
|
||||||
int daysInMonth() {
|
int daysInMonth() {
|
||||||
late int amountOfDays;
|
return DateTime(year, month + 1, 0).day;
|
||||||
|
|
||||||
switch (month) {
|
|
||||||
case DateTime.january:
|
|
||||||
case DateTime.march:
|
|
||||||
case DateTime.may:
|
|
||||||
case DateTime.july:
|
|
||||||
case DateTime.august:
|
|
||||||
case DateTime.october:
|
|
||||||
case DateTime.december:
|
|
||||||
amountOfDays = 31;
|
|
||||||
break;
|
|
||||||
case DateTime.april:
|
|
||||||
case DateTime.june:
|
|
||||||
case DateTime.september:
|
|
||||||
case DateTime.november:
|
|
||||||
amountOfDays = 30;
|
|
||||||
break;
|
|
||||||
case DateTime.february:
|
|
||||||
amountOfDays = isLeapYear ? 29 : 28;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return amountOfDays;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ class DateTimePickerController extends ChangeNotifier {
|
||||||
DateTimePickerController({
|
DateTimePickerController({
|
||||||
required this.theme,
|
required this.theme,
|
||||||
required this.highlightToday,
|
required this.highlightToday,
|
||||||
required this.alwaysUse24HourFormat,
|
|
||||||
required this.pickTime,
|
required this.pickTime,
|
||||||
required this.browsingDate,
|
required this.browsingDate,
|
||||||
required this.selectedDate,
|
required this.selectedDate,
|
||||||
|
this.alwaysUse24HourFormat,
|
||||||
this.header,
|
this.header,
|
||||||
this.wrongTimeDialog,
|
this.wrongTimeDialog,
|
||||||
this.markedDates,
|
this.markedDates,
|
||||||
|
|
|
@ -33,11 +33,11 @@ class MonthDateTimePickerSheet extends StatelessWidget {
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
DateFormat.yMMMM().format(
|
// use localization to get the month name
|
||||||
|
DateFormat.yMMMM(Localizations.localeOf(context).toString()).format(
|
||||||
dateTimePickerController.browsingDate,
|
dateTimePickerController.browsingDate,
|
||||||
),
|
),
|
||||||
style: theme.baseTheme.textStyle!
|
style: theme.baseTheme.textStyle!.copyWith(fontSize: 25),
|
||||||
.copyWith(fontSize: 25),
|
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
|
|
|
@ -43,7 +43,7 @@ class WeekDateTimePicker extends StatelessWidget {
|
||||||
: () async {
|
: () async {
|
||||||
TimeOfDay? timeOfDay;
|
TimeOfDay? timeOfDay;
|
||||||
|
|
||||||
DateTime selectedDate = date.daysOfWeek()[index];
|
var selectedDate = date.daysOfWeek()[index];
|
||||||
|
|
||||||
timeOfDay = const TimeOfDay(hour: 0, minute: 0);
|
timeOfDay = const TimeOfDay(hour: 0, minute: 0);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class WeekDateTimePicker extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime selectedDateTime = DateTime(
|
var selectedDateTime = DateTime(
|
||||||
selectedDate.year,
|
selectedDate.year,
|
||||||
selectedDate.month,
|
selectedDate.month,
|
||||||
selectedDate.day,
|
selectedDate.day,
|
||||||
|
@ -82,7 +82,7 @@ class WeekDateTimePicker extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Text(
|
Text(
|
||||||
DateFormat.E()
|
DateFormat.E(Localizations.localeOf(context).toString())
|
||||||
.format(
|
.format(
|
||||||
date.daysOfWeek().elementAt(index),
|
date.daysOfWeek().elementAt(index),
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,16 +20,17 @@ class WeekDateTimePickerSheet extends StatelessWidget {
|
||||||
final bool showHeader;
|
final bool showHeader;
|
||||||
final double weekDateBoxSize;
|
final double weekDateBoxSize;
|
||||||
|
|
||||||
String getDateHeader() {
|
String _getDateHeader(BuildContext context) {
|
||||||
List<DateTime> weekDays =
|
var weekDays =
|
||||||
dateTimePickerController.browsingDate.daysOfWeek();
|
dateTimePickerController.browsingDate.daysOfWeek();
|
||||||
|
|
||||||
String firstDay = weekDays.first.day.toString();
|
var firstDay = weekDays.first.day.toString();
|
||||||
|
|
||||||
String lastDay = weekDays.last.day.toString();
|
var lastDay = weekDays.last.day.toString();
|
||||||
|
|
||||||
String monthYear =
|
var monthYear =
|
||||||
DateFormat("MMMM, yyyy").format(dateTimePickerController.browsingDate);
|
DateFormat("MMMM, yyyy", Localizations.localeOf(context).toString())
|
||||||
|
.format(dateTimePickerController.browsingDate);
|
||||||
|
|
||||||
return '$firstDay - $lastDay $monthYear';
|
return '$firstDay - $lastDay $monthYear';
|
||||||
}
|
}
|
||||||
|
@ -50,7 +51,7 @@ class WeekDateTimePickerSheet extends StatelessWidget {
|
||||||
),
|
),
|
||||||
if (showHeader) ...[
|
if (showHeader) ...[
|
||||||
Text(
|
Text(
|
||||||
getDateHeader(),
|
_getDateHeader(context),
|
||||||
style: theme.baseTheme.textStyle!.copyWith(fontSize: 9),
|
style: theme.baseTheme.textStyle!.copyWith(fontSize: 9),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_date_time_picker
|
name: flutter_date_time_picker
|
||||||
description: A new Flutter package project.
|
description: A Flutter package for date and time picker.
|
||||||
version: 2.0.0
|
version: 2.1.0
|
||||||
homepage: https://iconica.nl/
|
homepage: https://iconica.nl/
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue