-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Labels
Description
can't mock timeZoneOffset.
Snippet
test('test', () {
final time = DateTime(2024, 1, 1, 19);
withClock(Clock.fixed(time), () {
final offset = clock.now().timeZoneOffset;
print(offset);
// some expects...
});
});Running this test on machines in different time zones prints different timeZoneOffset.
So, test can fail in another time zone.
What I want
Add timeZoneOffset overriding with clock.
Or, maybe, you can help me to resolve this issue with another solutions?...
dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
General info
- Dart 3.8.1 (stable) (Wed May 28 00:47:25 2025 -0700) on "macos_arm64"
- on macos / Version 15.6.1 (Build 24G90)
- locale is ru-RU
Project info
- sdk constraint: '^3.8.1'
- dependencies: auto_route, badges, barcode_widget, bloc, bloc_concurrency, bloc_event_transformers, bubble, calendar_date_picker2, carousel_slider, clock, collection, convert, cupertino_icons, dartx, decimal, dio, dio_smart_retry, dotted_border, dotted_line, drift, drift_flutter, equatable, eraser, excel, expandable, fast_immutable_collections, firebase_core, firebase_crashlytics, firebase_messaging, flutter, flutter_bloc, flutter_local_notifications, flutter_localizations, flutter_multi_formatter, flutter_pdfview, flutter_slidable, flutter_svg, formz, freezed_annotation, gap, get_it, hexcolor, html_unescape, huawei_hmsavailability, infinite_scroll_pagination, intl, json_annotation, logger, meta, mobile_scanner, package_info_plus, path_provider, permission_handler, provider, pull_down_button, qr_flutter, quiver, rxdart, screen_brightness, share_plus, shared_preferences, shimmer, slang, slang_flutter, sliver_tools, slivers, sprintf, syncfusion_flutter_pdf, table_calendar, table_sticky_headers, theme_tailor_annotation, top_modal_sheet, two_dimensional_scrollables, url_launcher, webview_flutter
- dev_dependencies: altive_lints, args, auto_route_generator, build_runner, custom_lint, downloadsfolder, drift_dev, flutter_gen_runner, flutter_launcher_icons, flutter_test, freezed, http_mock_adapter, integration_test, json_serializable, melos, mockito, path, path_provider_platform_interface, plugin_platform_interface, process_run, slang_build_runner, test, theme_tailor, webview_flutter_platform_interface, yaml
- elided dependencies: 9
Process info
| Memory | CPU | Elapsed time | Command line |
|---|---|---|---|
| 22 MB | 0.0% | 12:03:06 | dart devtools --machine --dtd-uri=ws:/Yp5mJExr5WU= |
| 489 MB | 0.0% | 12:03:06 | dart language-server --client-id=Android-Studio --client-version=AI-252.25557.131 --protocol=analyzer |
| 922 MB | 0.0% | 12:01:31 | dart lib/custom_lint_client.dart ::1 51031 |
| 3 MB | 0.0% | 01-15:40:55 | dart pub upgrade |
| 1 MB | 0.0% | 07-00:06:10 | dart pub upgrade |
| 1 MB | 0.0% | 10-14:26:04 | dart pub upgrade |
| 63 MB | 0.3% | 12:03:13 | flutter_tools.snapshot daemon |