-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Code that uses DateTime.now is untestable #28985
Copy link
Copy link
Open
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.core-nlibrary-asynclibrary-coretype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Metadata
Metadata
Assignees
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.core-nlibrary-asynclibrary-coretype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
For testing purposes it would be useful if there was a way to drive the dart:core clock manually, so that
DateTime.nowreturned predictable times. One solution would be to provide a hook in theZoneto drive it; this would letFakeAsyncdrive it in a manner consistent with the rest of theFakeAsyncclocks.Currently there is code in Flutter's framework that is untested and basically untestable because it depends on the value returned from DateTime.now (for example, the code that highlights "today" in the date picker).