From cc9290fa7212ca1fca13e87458e4cb9add4074ae Mon Sep 17 00:00:00 2001 From: FaKenKoala <60820399+FaKenKoala@users.noreply.github.com> Date: Thu, 11 May 2023 10:23:53 +0800 Subject: [PATCH] 1. colon as splitter is not longer supported in dart >= 3.0.0, replace with "=" 2. replace DatePickerTheme with DateTimePickerTheme to resolve conflict with flutter package DatePickerTheme --- .../ios/Flutter/flutter_export_environment.sh | 13 ++--- example/lib/main.dart | 2 +- lib/flutter_datetime_picker.dart | 51 +++++++++---------- lib/src/date_model.dart | 4 +- lib/src/datetime_picker_theme.dart | 4 +- pubspec.yaml | 4 +- 6 files changed, 38 insertions(+), 40 deletions(-) diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index da2211a4..8c2c98fa 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,16 +1,13 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/liuyanbo/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/liuyanbo/Documents/GitHub/flutter_datetime_picker/example" -export "FLUTTER_TARGET=/Users/liuyanbo/Documents/GitHub/flutter_datetime_picker/example/lib/main.dart" +export "FLUTTER_ROOT=/Users/wombat/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/wombat/FlutterProjects/workstation/flutter_datetime_picker/example" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build/ios" -export "OTHER_LDFLAGS=$(inherited) -framework Flutter" -export "FLUTTER_FRAMEWORK_DIR=/Users/liuyanbo/flutter/bin/cache/artifacts/engine/ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=flutter.inspector.structuredErrors%3Dtrue" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.packages" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/example/lib/main.dart b/example/lib/main.dart index 1ab0e793..637c3a58 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -108,7 +108,7 @@ class HomePage extends StatelessWidget { showTitleActions: true, minTime: DateTime(2018, 3, 5), maxTime: DateTime(2019, 6, 7), - theme: DatePickerTheme( + theme: DateTimePickerTheme( headerColor: Colors.orange, backgroundColor: Colors.blue, itemStyle: TextStyle( diff --git a/lib/flutter_datetime_picker.dart b/lib/flutter_datetime_picker.dart index dba6b566..249337c1 100644 --- a/lib/flutter_datetime_picker.dart +++ b/lib/flutter_datetime_picker.dart @@ -3,7 +3,6 @@ library flutter_datetime_picker; import 'dart:async'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/painting.dart'; import 'package:flutter_datetime_picker/src/datetime_picker_theme.dart'; import 'package:flutter_datetime_picker/src/date_model.dart'; import 'package:flutter_datetime_picker/src/i18n_model.dart'; @@ -22,15 +21,15 @@ class DatePicker { /// static Future showDatePicker( BuildContext context, { - bool showTitleActions: true, + bool showTitleActions = true, DateTime? minTime, DateTime? maxTime, DateChangedCallback? onChanged, DateChangedCallback? onConfirm, DateCancelledCallback? onCancel, - locale: LocaleType.en, + LocaleType locale = LocaleType.en, DateTime? currentTime, - DatePickerTheme? theme, + DateTimePickerTheme? theme, }) async { return await Navigator.push( context, @@ -58,14 +57,14 @@ class DatePicker { /// static Future showTimePicker( BuildContext context, { - bool showTitleActions: true, - bool showSecondsColumn: true, + bool showTitleActions = true, + bool showSecondsColumn = true, DateChangedCallback? onChanged, DateChangedCallback? onConfirm, DateCancelledCallback? onCancel, - locale: LocaleType.en, + LocaleType locale = LocaleType.en, DateTime? currentTime, - DatePickerTheme? theme, + DateTimePickerTheme? theme, }) async { return await Navigator.push( context, @@ -92,13 +91,13 @@ class DatePicker { /// static Future showTime12hPicker( BuildContext context, { - bool showTitleActions: true, + bool showTitleActions = true, DateChangedCallback? onChanged, DateChangedCallback? onConfirm, DateCancelledCallback? onCancel, - locale: LocaleType.en, + LocaleType locale = LocaleType.en, DateTime? currentTime, - DatePickerTheme? theme, + DateTimePickerTheme? theme, }) async { return await Navigator.push( context, @@ -124,15 +123,15 @@ class DatePicker { /// static Future showDateTimePicker( BuildContext context, { - bool showTitleActions: true, + bool showTitleActions = true, DateTime? minTime, DateTime? maxTime, DateChangedCallback? onChanged, DateChangedCallback? onConfirm, DateCancelledCallback? onCancel, - locale: LocaleType.en, + LocaleType locale = LocaleType.en, DateTime? currentTime, - DatePickerTheme? theme, + DateTimePickerTheme? theme, }) async { return await Navigator.push( context, @@ -160,13 +159,13 @@ class DatePicker { /// static Future showPicker( BuildContext context, { - bool showTitleActions: true, + bool showTitleActions = true, DateChangedCallback? onChanged, DateChangedCallback? onConfirm, DateCancelledCallback? onCancel, - locale: LocaleType.en, + LocaleType locale = LocaleType.en, BasePickerModel? pickerModel, - DatePickerTheme? theme, + DateTimePickerTheme? theme, }) async { return await Navigator.push( context, @@ -191,13 +190,13 @@ class _DatePickerRoute extends PopupRoute { this.onChanged, this.onConfirm, this.onCancel, - DatePickerTheme? theme, + DateTimePickerTheme? theme, this.barrierLabel, this.locale, RouteSettings? settings, BasePickerModel? pickerModel, }) : this.pickerModel = pickerModel ?? DatePickerModel(), - this.theme = theme ?? DatePickerTheme(), + this.theme = theme ?? DateTimePickerTheme(), super(settings: settings); final bool? showTitleActions; @@ -205,7 +204,7 @@ class _DatePickerRoute extends PopupRoute { final DateChangedCallback? onConfirm; final DateCancelledCallback? onCancel; final LocaleType? locale; - final DatePickerTheme theme; + final DateTimePickerTheme theme; final BasePickerModel pickerModel; @override @@ -293,7 +292,7 @@ class _DatePickerState extends State<_DatePickerComponent> { @override Widget build(BuildContext context) { - DatePickerTheme theme = widget.route.theme; + DateTimePickerTheme theme = widget.route.theme; return GestureDetector( child: AnimatedBuilder( animation: widget.route.animation!, @@ -326,7 +325,7 @@ class _DatePickerState extends State<_DatePickerComponent> { } } - Widget _renderPickerView(DatePickerTheme theme) { + Widget _renderPickerView(DateTimePickerTheme theme) { Widget itemView = _renderItemView(theme); if (widget.route.showTitleActions == true) { return Column( @@ -341,7 +340,7 @@ class _DatePickerState extends State<_DatePickerComponent> { Widget _renderColumnView( ValueKey key, - DatePickerTheme theme, + DateTimePickerTheme theme, StringAtIndexCallBack stringAtIndexCB, ScrollController scrollController, int layoutProportion, @@ -396,7 +395,7 @@ class _DatePickerState extends State<_DatePickerComponent> { ); } - Widget _renderItemView(DatePickerTheme theme) { + Widget _renderItemView(DateTimePickerTheme theme) { return Container( color: theme.backgroundColor, child: Directionality( @@ -471,7 +470,7 @@ class _DatePickerState extends State<_DatePickerComponent> { } // Title View - Widget _renderTitleActionsView(DatePickerTheme theme) { + Widget _renderTitleActionsView(DateTimePickerTheme theme) { final done = _localeDone(); final cancel = _localeCancel(); @@ -543,7 +542,7 @@ class _BottomPickerLayout extends SingleChildLayoutDelegate { final double progress; final int? itemCount; final bool? showTitleActions; - final DatePickerTheme theme; + final DateTimePickerTheme theme; final double bottomPadding; @override diff --git a/lib/src/date_model.dart b/lib/src/date_model.dart index 0e899870..a17120d6 100644 --- a/lib/src/date_model.dart +++ b/lib/src/date_model.dart @@ -377,7 +377,9 @@ class TimePickerModel extends CommonPickerModel { bool showSecondsColumn; TimePickerModel( - {DateTime? currentTime, LocaleType? locale, this.showSecondsColumn: true}) + {DateTime? currentTime, + LocaleType? locale, + this.showSecondsColumn = true}) : super(locale: locale) { this.currentTime = currentTime ?? DateTime.now(); diff --git a/lib/src/datetime_picker_theme.dart b/lib/src/datetime_picker_theme.dart index e3f616f4..2245cc5e 100644 --- a/lib/src/datetime_picker_theme.dart +++ b/lib/src/datetime_picker_theme.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; // Migrate DiagnosticableMixin to Diagnosticable until // https://github.com/flutter/flutter/pull/51495 makes it into stable (v1.15.21) -class DatePickerTheme with DiagnosticableTreeMixin { +class DateTimePickerTheme with DiagnosticableTreeMixin { final TextStyle cancelStyle; final TextStyle doneStyle; final TextStyle itemStyle; @@ -14,7 +14,7 @@ class DatePickerTheme with DiagnosticableTreeMixin { final double titleHeight; final double itemHeight; - const DatePickerTheme({ + const DateTimePickerTheme({ this.cancelStyle = const TextStyle(color: Colors.black54, fontSize: 16), this.doneStyle = const TextStyle(color: Colors.blue, fontSize: 16), this.itemStyle = const TextStyle(color: Color(0xFF000046), fontSize: 18), diff --git a/pubspec.yaml b/pubspec.yaml index caf42caf..d18ad2f0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: flutter_datetime_picker description: A date time picker for flutter, you can choose date / time / date&time in English Dutch and Chinese, and you can also custom your own picker content -version: 1.5.1 +version: 1.5.2 homepage: https://github.com/Realank/flutter_datetime_picker environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: flutter: