Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DateTime Picker "cancel" button behavior fix #1444

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions .github/workflows/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,10 @@ jobs:
with:
distribution: 'zulu'
java-version: '11'

- name: Get Flutter version by FVM
uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
with:
path: ".fvmrc"

- name: Flutter action
uses: subosito/flutter-action@v2
- name: Setup Flutter
uses: kuhnroyal/flutter-fvm-config-action/setup@v3
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
architecture: x64
cache: true

path: '.fvmrc'
- name: Install dependencies
run: flutter pub get
- name: Format code
Expand All @@ -59,9 +48,7 @@ jobs:
- name: Run tests
run: flutter test --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: codecov/codecov-action@v5
with:
files: coverage/lcov.info
name: flutter_form_builder
Expand Down
20 changes: 10 additions & 10 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "5.0.0"
flutter_localizations:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -99,18 +99,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
url: "https://pub.dev"
source: hosted
version: "10.0.8"
version: "10.0.7"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
url: "https://pub.dev"
source: hosted
version: "3.0.9"
version: "3.0.8"
leak_tracker_testing:
dependency: transitive
description:
Expand All @@ -123,10 +123,10 @@ packages:
dependency: transitive
description:
name: lints
sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
sha256: "4a16b3f03741e1252fda5de3ce712666d010ba2122f8e912c94f9f7b90e1a4c3"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "5.1.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -229,5 +229,5 @@ packages:
source: hosted
version: "14.3.0"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
sdk: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"

dependencies:
flutter:
Expand All @@ -18,7 +18,7 @@ dependencies:
intl: ^0.19.0

dev_dependencies:
flutter_lints: ^4.0.0
flutter_lints: ">=5.0.0 <6.0.0"
flutter_test:
sdk: flutter

Expand Down
2 changes: 0 additions & 2 deletions lib/flutter_form_builder.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
library flutter_form_builder;

export 'src/form_builder.dart';
export 'src/form_builder_field.dart';
export 'src/form_builder_field_decoration.dart';
Expand Down
17 changes: 10 additions & 7 deletions lib/src/fields/form_builder_date_time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class FormBuilderDateTimePicker extends FormBuilderFieldDecoration<DateTime> {
final SelectableDayPredicate? selectableDayPredicate;
final Offset? anchorPoint;
final EntryModeChangeCallback? onEntryModeChanged;
final bool barrierDismissible;

/// Creates field for `Date`, `Time` and `DateTime` input
FormBuilderDateTimePicker({
Expand Down Expand Up @@ -195,6 +196,7 @@ class FormBuilderDateTimePicker extends FormBuilderFieldDecoration<DateTime> {
this.selectableDayPredicate,
this.anchorPoint,
this.onEntryModeChanged,
this.barrierDismissible = true,
}) : super(
builder: (FormFieldState<DateTime?> field) {
final state = field as _FormBuilderDateTimePickerState;
Expand Down Expand Up @@ -284,7 +286,6 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
case InputType.date:
return DateFormat.yMd(languageCode);
case InputType.both:
default:
return DateFormat.yMd(languageCode).add_Hms();
}
}
Expand All @@ -306,11 +307,13 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
if (date != null) {
if (!mounted) break;
final time = await _showTimePicker(currentValue);
newValue = combine(date, time);
if (time == null) {
newValue = null;
} else {
newValue = combine(date, time);
}
}
break;
default:
throw 'Unexpected input type ${widget.inputType}';
}
if (!mounted) return null;
final finalValue = newValue ?? currentValue;
Expand Down Expand Up @@ -342,6 +345,7 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
currentDate: widget.currentDate,
anchorPoint: widget.anchorPoint,
keyboardType: widget.keyboardType,
barrierDismissible: widget.barrierDismissible,
);
}

Expand All @@ -360,7 +364,7 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
};
}

final timePickerResult = await showTimePicker(
return await showTimePicker(
context: context,
initialTime: currentValue != null
? TimeOfDay.fromDateTime(currentValue)
Expand All @@ -375,9 +379,8 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
anchorPoint: widget.anchorPoint,
errorInvalidText: widget.errorInvalidText,
onEntryModeChanged: widget.onEntryModeChanged,
barrierDismissible: widget.barrierDismissible,
);
return timePickerResult ??
(currentValue != null ? TimeOfDay.fromDateTime(currentValue) : null);
}

/// Sets the hour and minute of a [DateTime] from a [TimeOfDay].
Expand Down
1 change: 0 additions & 1 deletion lib/src/widgets/grouped_radio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ class _GroupedRadioState<T> extends State<GroupedRadio<T?>> {
child: Row(children: widgetList),
);
case OptionsOrientation.wrap:
default:
return SingleChildScrollView(
child: Wrap(
spacing: widget.wrapSpacing,
Expand Down
20 changes: 10 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "5.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -79,18 +79,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
url: "https://pub.dev"
source: hosted
version: "10.0.8"
version: "10.0.7"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
url: "https://pub.dev"
source: hosted
version: "3.0.9"
version: "3.0.8"
leak_tracker_testing:
dependency: transitive
description:
Expand All @@ -103,10 +103,10 @@ packages:
dependency: transitive
description:
name: lints
sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
sha256: "3315600f3fb3b135be672bf4a178c55f274bebe368325ae18462c89ac1e3b413"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "5.0.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -209,5 +209,5 @@ packages:
source: hosted
version: "14.3.0"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"
8 changes: 5 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ funding:
- https://opencollective.com/flutter-form-builder-ecosystem

environment:
sdk: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
sdk: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"

dependencies:
flutter:
sdk: flutter
# This version would be max, the same version used on flutter_localizations
# https://github.com/flutter/flutter/blob/17025dd88227cd9532c33fa78f5250d548d87e9a/packages/flutter_localizations/pubspec.yaml#L14
intl: ">=0.19.0 <0.20.0"

dev_dependencies:
flutter_lints: ^4.0.0
flutter_lints: ">=5.0.0 <6.0.0"
flutter_test:
sdk: flutter
Loading