nilts_clock

nilts_clock provides lint rules, quick fixes, and assists for Dart and Flutter projects using the clock package to help you enforce best practices and prevent errors.

build pub license


Contents

Usage

Note: nilts_clock no longer supports custom_lint. If you're using custom_lint, please use nilts_clock versions below v1.0 and refer to README_CUSTOM_LINT.md.

If you're using Dart SDK version 3.10 or later, add nilts_clock to the top-level plugins section of your analysis_options.yaml file:

plugins:
  nilts_clock: ^1.0.0

Configuration

All lint rules in nilts_clock are disabled by default.

This is because rules defined in warnings cannot currently be disabled individually. By using diagnostics, you can enable only the rules you need.

To enable rules, use the map format with version: and diagnostics::

plugins:
  nilts_clock:
    version: ^1.0.0
    diagnostics:
      using_date_time_now: true

For a complete example of enabling all rules, see analysis_options.yaml.

See also:

Lint rules and quick fixes

See below to learn what each lint rule does. Some rules support quick fixes in your IDE.

Quick fix demo

Overview

Rule name Overview Target SDK Rule type Maturity level Severity Quick fix
using_date_time_now Checks if DateTime.now() is used. Any versions nilts_clock supports ErrorProne Stable Info ✅️

Details

using_date_time_now

  • Target SDK : Any versions nilts_clock supports
  • Rule type : ErrorProne
  • Maturity level : Stable
  • Severity : Info
  • Quick fix : ✅

DON'T use DateTime.now().

If your project depends on the clock package and expects the current time to be encapsulated, always use clock.now() instead for consistency.

BAD:

final dateTimeNow = DateTime.now();

GOOD:

final clockNow = clock.now();

See also:

Assists

Coming soon... 🚀

Feature requests

Have a feature request? Please create an issue using this template.

Bug reports

Found a bug? Please create an issue using this template.

Contributing

Contributions are welcome! Please read the CONTRIBUTING guide before submitting your PR.

Libraries

main
nilts_clock
This file exists to satisfy the pub naming convention.