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: revert intl to 0.18.1 for wider compatibility #66

Merged
merged 1 commit into from
May 8, 2024
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
33 changes: 22 additions & 11 deletions lib/src/components/date_input/date_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import '../../../zeta_flutter.dart';
class ZetaDateInput extends StatefulWidget {
/// Constructor for [ZetaDateInput].
///
/// Example usage how to provide custom validanions
/// Example usage how to provide custom validations
/// via `onChanged`, `hasError` and `errorText`:
/// ```dart
/// ZetaDateInput(
/// label: 'Birthdate',
/// hint: 'Enter birthdate',
/// label: 'Birthday',
/// hint: 'Enter birthday',
/// hasError: _errorText != null,
/// errorText: _errorText ?? 'Invalid date',
/// onChanged: (value) {
Expand All @@ -24,7 +24,7 @@ class ZetaDateInput extends StatefulWidget {
/// setState(
/// () => _errorText = value.difference(
/// DateTime(now.year, now.month, now.day)).inDays > 0
/// ? 'Birthdate cannot be in the future'
/// ? 'Birthday cannot be in the future'
/// : null,
/// );
/// },
Expand All @@ -44,6 +44,7 @@ class ZetaDateInput extends StatefulWidget {
});

/// Determines the size of the input field.
///
/// Default is `ZetaDateInputSize.large`
final ZetaWidgetSize? size;

Expand All @@ -60,23 +61,22 @@ class ZetaDateInput extends StatefulWidget {
final bool rounded;

/// Determines if the input field should be displayed in error style.
///
/// Default is `false`.
///
/// If `enabled` is `false`, this has no effect.
final bool hasError;

/// In combination with `hasError: true`, provides the error message
/// to be displayed below the input field.
/// In combination with `hasError: true`, provides the error message to be displayed below the input field.
///
/// If `hasError` is false, then `errorText` should provide
/// date validation error message.
/// If `hasError` is false, then `errorText` should provide date validation error message.
///
/// See the example in the [ZetaDateInput] documentation.
final String? errorText;

/// A callback, which provides the entered date, or `null`, if invalid.
///
/// See the example in the [ZetaDateInput] documentation
/// how to provide custom validations
/// See the example in the [ZetaDateInput] documentation how to provide custom validations
/// in combination with `hasError` and `errorText`.
final void Function(DateTime?)? onChanged;

Expand Down Expand Up @@ -253,7 +253,7 @@ class _ZetaDateInputState extends State<ZetaDateInput> {
child: Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 8),
padding: const EdgeInsets.only(right: ZetaSpacing.x2),
child: Icon(
showError && widget.enabled
? (widget.rounded ? ZetaIcons.error_round : ZetaIcons.error_sharp)
Expand Down Expand Up @@ -316,3 +316,14 @@ class _ZetaDateInputState extends State<ZetaDateInput> {
borderSide: BorderSide(color: zeta.colors.red.shade50),
);
}

extension on DateFormat {
//NOTE: this function is a part of intl 0.19.0.
DateTime? tryParseStrict(String inputString) {
try {
return parseStrict(inputString);
} on FormatException {
return null;
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
flutter:
sdk: flutter
flutter_slidable: ^3.1.0
intl: ^0.19.0
intl: ^0.18.1
mask_text_input_formatter: ^2.9.0

dev_dependencies:
Expand Down
Loading