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

setting maxUnitOfTime to hours gives me an error #5

Closed
JoseGeorges8 opened this issue Jan 7, 2021 · 1 comment
Closed

setting maxUnitOfTime to hours gives me an error #5

JoseGeorges8 opened this issue Jan 7, 2021 · 1 comment

Comments

@JoseGeorges8
Copy link

Hi!

Great package I was about to create a function to format the time like your relative function, but you have it!

However I can't seem to understand why I get this error when I try to set maxUnitOfTime: UnitOfTime.hour

This is the error:

The method '>' was called on null.
Receiver: null
Tried calling: >(0)

When the exception was thrown, this was the stack: 
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      DateTimeFormat.relative.<anonymous closure> (package:date_time_format/src/date_time_format.dart:409:65)
#2      ListMixin.indexWhere (dart:collection/list.dart:496:15)
#3      DateTimeFormat.relative (package:date_time_format/src/date_time_format.dart:409:37)
#4      DateTimeFormatter.relative (package:date_time_format/src/date_time_extension_methods.dart:144:27)

And this is the code:

    print(dateTime); // 2021-01-05 22:01:43.000Z
    print(DateTime.now()); // 2021-01-06 19:29:04.152148

'${DateTime.now().relative(to: dateTime, round: false, appendIfAfter: 'left', levelOfPrecision: 2, maxUnitOfTime: UnitOfTime.hour)}';

If I remove the maxUnitOfTime works fine, but I'd rather not show the days if possible.

Thanks!

@james-alex
Copy link
Owner

Hello,

Thanks for reporting this bug. It's been fixed in v1.1.1, now on pub.dev.

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

No branches or pull requests

2 participants