Skip to content

fix: LocalDate toString error#62

Open
amondnet wants to merge 1 commit intoDana-Ferguson:masterfrom
amondnet:fix/localdate-tostring
Open

fix: LocalDate toString error#62
amondnet wants to merge 1 commit intoDana-Ferguson:masterfrom
amondnet:fix/localdate-tostring

Conversation

@amondnet
Copy link
Copy Markdown

@amondnet amondnet commented Jun 4, 2021

Error Logs

type '(LocalDate, StringBuffer) => void' is not a subtype of type 'Object' of 'value'
               type '(LocalDate, StringBuffer) => void' is not a subtype of type 'Object' of 'value'
               #0      List.add (dart:core-patch/growable_array.dart)
               #1      SteppedPatternBuilder.addFormatAction (package:time_machine/src/text/patterns/stepped_pattern_builder.dart:142:88)
               #2      DatePatternHelper.createDayHandler.<anonymous closure> (package:time_machine/src/text/patterns/date_pattern_helper.dart:127:19)
               #3      SteppedPatternBuilder.parseCustomPattern (package:time_machine/src/text/patterns/stepped_pattern_builder.dart:72:16)
               #4      LocalDatePatternParser.parsePattern (package:time_machine/src/text/localdate_pattern_parser.dart:62:20)
               #5      new FixedFormatInfoPatternParser.<anonymous closure> (package:time_machine/src/text/fixed_format_info_pattern_parser.dart:21:88)
               #6      Cache.getOrAdd (package:time_machine/src/utility/cache.dart:55:32)
               #7      FixedFormatInfoPatternParser.parsePattern (package:time_machine/src/text/fixed_format_info_pattern_parser.dart:26:54)
               #8      LocalDatePatterns.format (package:time_machine/src/text/localdate_pattern.dart:26:12)
               #9      LocalDate.toString (package:time_machine/src/localdate.dart:591:25)

@SteveAlexander
Copy link
Copy Markdown
Collaborator

Thanks for posting a fix here. Couple of things we should consider:

  1. This is caused by a bug in Dart that manifests only on Android. The bug is here, and is now closed: type '(String, StringBuffer) => Null' is not a subtype of type 'Object' of 'value' dart-lang/sdk#46165

So, the fix will be available in a Dart version pretty soon. If we make this change to time_machine, I expect we'll want to revert it once the Dart fix hits the stable channel.

  1. I think it would be better to use Object? than dynamic as a temporary workaround, as it's more explicit about what the type is.

Interested in hearing your thoughts on these!

Thanks again for offering this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants