diff --git a/analysis_options.yaml b/analysis_options.yaml index d8569d7..e3bb8d3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -32,10 +32,8 @@ linter: prefer_iterable_whereType: true prefer_function_declarations_over_variables: true unnecessary_lambdas: true - prefer_equal_for_default_values: true avoid_init_to_null: true unnecessary_getters_setters: true - unnecessary_getters: true prefer_expression_function_bodies: true unnecessary_this: true unnecessary_const: true @@ -51,11 +49,10 @@ linter: prefer_final_fields: true use_setters_to_change_properties: true avoid_setters_without_getters: true - avoid_returning_null: true avoid_returning_this: true type_annotate_public_apis: true prefer_typing_uninitialized_variables: true -# omit_local_variable_types: true + # omit_local_variable_types: true avoid_types_on_closure_parameters: true avoid_return_types_on_setters: true prefer_generic_function_type_aliases: true @@ -66,11 +63,9 @@ linter: avoid_equals_and_hash_code_on_mutable_classes: true avoid_null_checks_in_equality_operators: true - # PEDANTIC # (duplicated rules are removed) always_declare_return_types: true - always_require_non_null_named_parameters: true annotate_overrides: true avoid_empty_else: true avoid_shadowing_type_parameters: true @@ -83,7 +78,7 @@ linter: prefer_contains: true prefer_for_elements_to_map_fromIterable: true prefer_if_null_operators: true -# prefer_single_quotes: true + # prefer_single_quotes: true prefer_spread_collections: true recursive_getters: true type_init_formals: true @@ -91,4 +86,4 @@ linter: unnecessary_new: true unnecessary_null_in_if_null_operators: true unrelated_type_equality_checks: true - valid_regexps: true \ No newline at end of file + valid_regexps: true diff --git a/example/lib/date_pickers_widgets/day_picker_page.dart b/example/lib/date_pickers_widgets/day_picker_page.dart index c7ff3a1..0391b38 100644 --- a/example/lib/date_pickers_widgets/day_picker_page.dart +++ b/example/lib/date_pickers_widgets/day_picker_page.dart @@ -44,7 +44,7 @@ class _DayPickerPageState extends State { dp.DatePickerRangeStyles styles = dp.DatePickerRangeStyles( selectedDateStyle: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: selectedDateStyleColor), selectedSingleDateDecoration: BoxDecoration( color: selectedSingleDateDecorationColor, @@ -88,7 +88,7 @@ class _DayPickerPageState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Padding( padding: const EdgeInsets.symmetric(vertical: 12.0), diff --git a/example/lib/date_pickers_widgets/days_picker_page.dart b/example/lib/date_pickers_widgets/days_picker_page.dart index dd78dff..a720f44 100644 --- a/example/lib/date_pickers_widgets/days_picker_page.dart +++ b/example/lib/date_pickers_widgets/days_picker_page.dart @@ -52,7 +52,7 @@ class _DaysPickerPageState extends State { dp.DatePickerRangeStyles styles = dp.DatePickerRangeStyles( selectedDateStyle: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: selectedDateStyleColor), selectedSingleDateDecoration: BoxDecoration( color: selectedSingleDateDecorationColor, shape: BoxShape.circle)); @@ -86,7 +86,7 @@ class _DaysPickerPageState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Padding( padding: const EdgeInsets.symmetric(vertical: 12.0), diff --git a/example/lib/date_pickers_widgets/month_picker_page.dart b/example/lib/date_pickers_widgets/month_picker_page.dart index 956d707..dc25115 100644 --- a/example/lib/date_pickers_widgets/month_picker_page.dart +++ b/example/lib/date_pickers_widgets/month_picker_page.dart @@ -32,7 +32,7 @@ class _MonthPickerPageState extends State { dp.DatePickerStyles styles = dp.DatePickerStyles( selectedDateStyle: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: selectedDateStyleColor), selectedSingleDateDecoration: BoxDecoration( color: selectedSingleDateDecorationColor, shape: BoxShape.circle)); @@ -60,7 +60,7 @@ class _MonthPickerPageState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Padding( padding: const EdgeInsets.symmetric(vertical: 12.0), diff --git a/example/lib/date_pickers_widgets/months_picker_page.dart b/example/lib/date_pickers_widgets/months_picker_page.dart index 06f196c..35a514e 100644 --- a/example/lib/date_pickers_widgets/months_picker_page.dart +++ b/example/lib/date_pickers_widgets/months_picker_page.dart @@ -32,7 +32,7 @@ class _MonthsPickerPageState extends State { dp.DatePickerStyles styles = dp.DatePickerStyles( selectedDateStyle: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: selectedDateStyleColor), selectedSingleDateDecoration: BoxDecoration( color: selectedSingleDateDecorationColor, shape: BoxShape.circle)); @@ -60,7 +60,7 @@ class _MonthsPickerPageState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Padding( padding: const EdgeInsets.symmetric(vertical: 12.0), diff --git a/example/lib/date_pickers_widgets/range_picker_page.dart b/example/lib/date_pickers_widgets/range_picker_page.dart index 48f1ac3..e9facd3 100644 --- a/example/lib/date_pickers_widgets/range_picker_page.dart +++ b/example/lib/date_pickers_widgets/range_picker_page.dart @@ -87,7 +87,7 @@ class _RangePickerPageState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), _stylesBlock(), _selectedBlock() diff --git a/example/lib/date_pickers_widgets/range_picker_styled.dart b/example/lib/date_pickers_widgets/range_picker_styled.dart index 2735ceb..da9c1d4 100644 --- a/example/lib/date_pickers_widgets/range_picker_styled.dart +++ b/example/lib/date_pickers_widgets/range_picker_styled.dart @@ -113,7 +113,7 @@ class _RangePickerPageStyledState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), _selectedBlock() ], diff --git a/example/lib/date_pickers_widgets/week_picker_page.dart b/example/lib/date_pickers_widgets/week_picker_page.dart index 64eac10..f062524 100644 --- a/example/lib/date_pickers_widgets/week_picker_page.dart +++ b/example/lib/date_pickers_widgets/week_picker_page.dart @@ -81,7 +81,7 @@ class _WeekPickerPageState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), _stylesBlock(), _selectedBlock() @@ -222,7 +222,7 @@ class _WeekPickerPageState extends State { borderRadius: BorderRadius.all(Radius.circular(3.0))); TextStyle? whiteText = - Theme.of(context).textTheme.bodyText2?.copyWith(color: Colors.white); + Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.white); return isEventDate ? EventDecoration(boxDecoration: roundedBorder, textStyle: whiteText) diff --git a/example/lib/date_pickers_widgets/year_picker_page.dart b/example/lib/date_pickers_widgets/year_picker_page.dart index b283904..0a564aa 100644 --- a/example/lib/date_pickers_widgets/year_picker_page.dart +++ b/example/lib/date_pickers_widgets/year_picker_page.dart @@ -32,7 +32,7 @@ class _YearPickerPageState extends State { dp.DatePickerStyles styles = dp.DatePickerStyles( selectedDateStyle: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: selectedDateStyleColor), selectedSingleDateDecoration: BoxDecoration( color: selectedSingleDateDecorationColor, shape: BoxShape.circle)); @@ -60,7 +60,7 @@ class _YearPickerPageState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Padding( padding: const EdgeInsets.symmetric(vertical: 12.0), diff --git a/example/lib/date_pickers_widgets/years_picker_page.dart b/example/lib/date_pickers_widgets/years_picker_page.dart index eaca93f..3c588b6 100644 --- a/example/lib/date_pickers_widgets/years_picker_page.dart +++ b/example/lib/date_pickers_widgets/years_picker_page.dart @@ -32,7 +32,7 @@ class _YearsPickerPageState extends State { dp.DatePickerStyles styles = dp.DatePickerStyles( selectedDateStyle: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: selectedDateStyleColor), selectedSingleDateDecoration: BoxDecoration( color: selectedSingleDateDecorationColor, shape: BoxShape.circle)); @@ -60,7 +60,7 @@ class _YearsPickerPageState extends State { children: [ Text( "Selected date styles", - style: Theme.of(context).textTheme.subtitle1, + style: Theme.of(context).textTheme.titleMedium, ), Padding( padding: const EdgeInsets.symmetric(vertical: 12.0), diff --git a/example/lib/main.dart b/example/lib/main.dart index 01cda00..2ebb14a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -92,7 +92,7 @@ class _MyHomePageState extends State with TickerProviderStateMixin { data: Theme.of(context).copyWith( canvasColor: Colors.blueGrey, textTheme: Theme.of(context).textTheme.copyWith( - caption: TextStyle(color: Colors.white.withOpacity(0.5)))), + bodySmall: TextStyle(color: Colors.white.withOpacity(0.5)))), child: BottomNavigationBar( type: BottomNavigationBarType.fixed, items: [ diff --git a/example/pubspec.lock b/example/pubspec.lock index a7c4b91..fa36941 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,58 +5,58 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.0.8" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -68,7 +68,7 @@ packages: path: ".." relative: true source: path - version: "0.3.0" + version: "0.4.2" flutter_localizations: dependency: "direct main" description: flutter @@ -78,9 +78,10 @@ packages: dependency: "direct main" description: name: flutter_material_color_picker - url: "https://pub.dartlang.org" + sha256: ca1e7749d228c9155ea24bce98e647cdbffa350e6f334f6c001f841cd3d9c987 + url: "https://pub.dev" source: hosted - version: "1.1.0+2" + version: "1.2.0" flutter_test: dependency: "direct dev" description: flutter @@ -90,37 +91,66 @@ packages: dependency: transitive description: name: intl - url: "https://pub.dartlang.org" + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" source: hosted - version: "0.17.0" + version: "0.18.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" source: hosted - version: "0.1.4" + version: "0.8.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.11.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -130,51 +160,66 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" source: hosted - version: "0.4.9" + version: "0.6.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" sdks: - dart: ">=2.17.0-0 <3.0.0" - flutter: ">=1.17.0" + dart: ">=3.2.0-0 <4.0.0" + flutter: ">=3.3.0" diff --git a/lib/src/day_based_changable_picker.dart b/lib/src/day_based_changable_picker.dart index 631f82b..c9bf632 100644 --- a/lib/src/day_based_changable_picker.dart +++ b/lib/src/day_based_changable_picker.dart @@ -1,8 +1,9 @@ +// ignore_for_file: comment_references + import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; - import 'package:intl/intl.dart' as intl; import 'basic_day_based_widget.dart'; @@ -160,6 +161,8 @@ class _DayBasedChangeablePickerState final ThemeData theme = Theme.of(context); _resultStyles = widget.datePickerStyles.fulfillWithTheme(theme); + + widget.selectablePicker.onDayTapped(widget.selection.earliest); } @override diff --git a/lib/src/i_selectable_picker.dart b/lib/src/i_selectable_picker.dart index 2fabb2c..1649dcb 100644 --- a/lib/src/i_selectable_picker.dart +++ b/lib/src/i_selectable_picker.dart @@ -1,3 +1,5 @@ +// ignore_for_file: comment_references + import 'dart:async'; import 'package:flutter/material.dart'; @@ -66,7 +68,9 @@ abstract class ISelectablePicker { /// If [_selectableDayPredicate] is set checks it as well. @protected bool isDisabled(DateTime day) => - day.isAfter(lastDate) || day.isBefore(firstDate) || !_selectableDayPredicate(day); + day.isAfter(lastDate) || + day.isBefore(firstDate) || + !_selectableDayPredicate(day); /// Closes [onUpdateController]. /// After it [onUpdateController] can't get new events. diff --git a/lib/src/month_picker.dart b/lib/src/month_picker.dart index b9d79d4..a522c96 100644 --- a/lib/src/month_picker.dart +++ b/lib/src/month_picker.dart @@ -191,22 +191,15 @@ class _MonthPickerState extends State> { void didChangeDependencies() { super.didChangeDependencies(); - try { - locale = Localizations.localeOf(context); - - MaterialLocalizations? curLocalizations = - Localizations.of( - context, MaterialLocalizations); - if (curLocalizations != null && localizations != curLocalizations) { - localizations = curLocalizations; - } + locale = Localizations.localeOf(context); - textDirection = Directionality.of(context); + MaterialLocalizations? curLocalizations = + Localizations.of(context, MaterialLocalizations); + if (curLocalizations != null && localizations != curLocalizations) { + localizations = curLocalizations; + } - // No MaterialLocalizations or Directionality or Locale was found - // and ".of" method throws error - // trying to cast null to MaterialLocalizations. - } on TypeError catch (_) {} + textDirection = Directionality.of(context); } @override diff --git a/lib/src/range_picker.dart b/lib/src/range_picker.dart index 10d2429..65b4547 100644 --- a/lib/src/range_picker.dart +++ b/lib/src/range_picker.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; import 'date_period.dart'; import 'date_picker_keys.dart'; diff --git a/lib/src/styles/date_picker_styles.dart b/lib/src/styles/date_picker_styles.dart index 41b6a37..8f48c18 100644 --- a/lib/src/styles/date_picker_styles.dart +++ b/lib/src/styles/date_picker_styles.dart @@ -101,18 +101,18 @@ class DatePickerStyles { Color accentColor = theme.colorScheme.secondary; TextStyle? _displayedPeriodTitle = - displayedPeriodTitle ?? theme.textTheme.subtitle1; + displayedPeriodTitle ?? theme.textTheme.titleMedium; TextStyle? _currentDateStyle = currentDateStyle ?? - theme.textTheme.bodyText1?.copyWith(color: theme.colorScheme.secondary); + theme.textTheme.bodyLarge?.copyWith(color: theme.colorScheme.secondary); TextStyle? _disabledDateStyle = disabledDateStyle ?? - theme.textTheme.bodyText2?.copyWith(color: theme.disabledColor); + theme.textTheme.bodyMedium?.copyWith(color: theme.disabledColor); TextStyle? _selectedDateStyle = selectedDateStyle ?? - theme.textTheme.bodyText1?.copyWith( + theme.textTheme.bodyLarge?.copyWith( color: theme.colorScheme.onSecondary, ); TextStyle? _defaultDateTextStyle = - defaultDateTextStyle ?? theme.textTheme.bodyText2; + defaultDateTextStyle ?? theme.textTheme.bodyMedium; BoxDecoration _selectedSingleDateDecoration = selectedSingleDateDecoration ?? BoxDecoration( @@ -121,7 +121,7 @@ class DatePickerStyles { DayHeaderStyle? _dayHeaderStyle = dayHeaderStyle; if (dayHeaderStyleBuilder == null && _dayHeaderStyle == null) { - _dayHeaderStyle = DayHeaderStyle(textStyle: theme.textTheme.caption); + _dayHeaderStyle = DayHeaderStyle(textStyle: theme.textTheme.bodySmall); } return DatePickerStyles( @@ -159,7 +159,7 @@ class DatePickerStyles { } @override - int get hashCode => hashValues( + int get hashCode => Object.hash( displayedPeriodTitle, currentDateStyle, disabledDateStyle, @@ -348,7 +348,7 @@ class DatePickerRangeStyles extends DatePickerStyles { } @override - int get hashCode => hashValues( + int get hashCode => Object.hash( selectedPeriodStartDecoration, selectedPeriodStartTextStyle, selectedPeriodLastDecoration, @@ -395,5 +395,5 @@ class DayHeaderStyle { } @override - int get hashCode => hashValues(textStyle, decoration); + int get hashCode => Object.hash(textStyle, decoration); } diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 9c2fc9d..1a14444 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -1,5 +1,7 @@ /// Bunch of useful functions for date pickers. class DatePickerUtils { + DatePickerUtils._(); + /// Returns if two objects have same year, month and day. /// Time doesn't matter. static bool sameDate(DateTime dateTimeOne, DateTime dateTimeTwo) => diff --git a/lib/src/week_picker.dart b/lib/src/week_picker.dart index db25b79..d4cc88e 100644 --- a/lib/src/week_picker.dart +++ b/lib/src/week_picker.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; import 'date_period.dart'; import 'date_picker_keys.dart'; diff --git a/lib/src/year_picker.dart b/lib/src/year_picker.dart index af9afeb..6da12ba 100644 --- a/lib/src/year_picker.dart +++ b/lib/src/year_picker.dart @@ -202,22 +202,15 @@ class _YearPickerState extends State> { void didChangeDependencies() { super.didChangeDependencies(); - try { - locale = Localizations.localeOf(context); - - MaterialLocalizations? curLocalizations = - Localizations.of( - context, MaterialLocalizations); - if (curLocalizations != null && localizations != curLocalizations) { - localizations = curLocalizations; - } + locale = Localizations.localeOf(context); - textDirection = Directionality.of(context); + MaterialLocalizations? curLocalizations = + Localizations.of(context, MaterialLocalizations); + if (curLocalizations != null && localizations != curLocalizations) { + localizations = curLocalizations; + } - // No MaterialLocalizations or Directionality or Locale was found - // and ".of" method throws error - // trying to cast null to MaterialLocalizations. - } on TypeError catch (_) {} + textDirection = Directionality.of(context); } @override diff --git a/pubspec.lock b/pubspec.lock index 199d9e6..e288a2c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,51 +5,50 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -69,37 +68,66 @@ packages: dependency: "direct main" description: name: intl - url: "https://pub.dartlang.org" + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" source: hosted - version: "0.17.0" + version: "2.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" source: hosted - version: "0.1.4" + version: "0.8.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.11.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -109,50 +137,65 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" source: hosted - version: "0.4.9" + version: "0.6.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=3.2.0-0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 95364fa..371f1f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: flutter_date_pickers description: Flutter package for day, week, range and month date pickers. -version: 0.4.2 +version: 0.5.0 homepage: https://github.com/MariaMelnik/flutter_date_pickers issue_tracker: https://github.com/MariaMelnik/flutter_date_pickers/issues environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=3.0.0 <4.0.0" dependencies: flutter: diff --git a/test/day_selectable_test.dart b/test/day_selectable_test.dart index 200e324..bf991f5 100644 --- a/test/day_selectable_test.dart +++ b/test/day_selectable_test.dart @@ -41,7 +41,7 @@ void main() { // ignore: prefer_function_declarations_over_variables final selectablePredicate = - (DateTime d) => !DatePickerUtils.sameDate(d, disabledDate); + (d) => !DatePickerUtils.sameDate(d, disabledDate); final selectableLogic = DaySelectable(selectedDate, firstDate, lastDate, selectableDayPredicate: selectablePredicate); diff --git a/test/range_selectable_test.dart b/test/range_selectable_test.dart index 0e057f5..eb605d7 100644 --- a/test/range_selectable_test.dart +++ b/test/range_selectable_test.dart @@ -2,7 +2,6 @@ import 'package:flutter_date_pickers/flutter_date_pickers.dart'; import 'package:flutter_date_pickers/src/day_type.dart'; import 'package:flutter_date_pickers/src/i_selectable_picker.dart'; import 'package:flutter_date_pickers/src/utils.dart'; - import 'package:flutter_test/flutter_test.dart'; void main() { @@ -48,7 +47,8 @@ void main() { final middlePeriodDateType = selectableLogic.getDayType(date); expect(middlePeriodDateType, DayType.middle, reason: "Incorrect DayType for the date ${date.toString()} " - "in period ${startPeriod.toString()} - ${endPeriod.toString()}"); + "in period ${startPeriod.toString()} " + "- ${endPeriod.toString()}"); } }); }); @@ -78,4 +78,4 @@ void main() { expect(selectableLogic.firstDate, startOfTheFirstDate); expect(selectableLogic.lastDate, endOfTheLastDate); }); -} \ No newline at end of file +}