Skip to content

Duration(seconds:) parsing problem #60586

Open
@rocketnik

Description

@rocketnik

There exists a case where the Duration created from an int seconds results in an unexpected value.

Steps to reproduce

  • evaluate Duration(seconds: 66666666666666660).inSeconds == 133584280340

This returns true. I would expect it to return false.

I see two options for how this could be resolved:

  • The .inSeconds should return the value that was used during initialization.
  • Alternatively if the seconds value is not valid (too large) Duration(seconds:) should throw or return null during initialization.

Infos about the environment:

  • I ran from Android Studio on ARM Mac on an iOS Simulator

Tooling:

  • Dart 3.7.2 (stable) (Tue Mar 11 04:27:50 2025 -0700) on "macos_arm64"
  • on macos / Version 15.3.2 (Build 24D81)
  • locale is en-DE

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-coretype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions