zuke.tools.dart

← Python API reference

@zuke/dart 1.0.0: @zuke/dart — typed DartTasks wrappers for the [Dart](https://dart.dev) CLI, for use in Zuke builds: analyze, format, fix and test Dart code, compile it to every target, generate docs, scaffold and run programs, and manage pub dependencies.

Symbols

#

DartAnalyzeSettings

class
class DartAnalyzeSettings(DartSettings)

Settings for dart analyze.

  • path(path: str) -> Self

    A file or directory to analyze (defaults to the current one); repeatable.

  • fatal_infos() -> Self

    Treat info-level issues as fatal (--fatal-infos).

  • no_fatal_warnings() -> Self

    Do not fail on warnings (--no-fatal-warnings).

  • format(name: Literal['default', 'json', 'machine']) -> Self

    The output format: default, json or machine (--format).

  • packages(path: str) -> Self

    The package resolution file to use (--packages).

#

DartCreateSettings

class
class DartCreateSettings(DartSettings)

Settings for dart create.

  • dir(path: str) -> Self

    The directory to create the project in; required.

  • template(name: Literal['cli', 'console', 'package', 'server-shelf', 'web']) -> Self

    The project template, instead of console (--template).

  • no_pub() -> Self

    Skip the implicit dart pub get (--no-pub).

  • force() -> Self

    Create into a directory that already exists (--force).

#

DartDocSettings

class
class DartDocSettings(DartSettings)

Settings for dart doc.

  • dir(path: str) -> Self

    The package directory to document (defaults to the current one).

  • output(path: str) -> Self

    Where to write the generated docs, instead of doc/api (--output).

  • validate_links() -> Self

    Check the generated docs for broken links (--validate-links).

  • dry_run() -> Self

    Report what would be documented without writing files (--dry-run).

#

DartFixSettings

class
class DartFixSettings(DartSettings)

Settings for dart fix.

  • dir(path: str) -> Self

    The directory to fix (defaults to the current one).

  • apply() -> Self

    Apply the proposed fixes (--apply). Without it or .dryRun(), dart fix only prints usage.

  • dry_run() -> Self

    List the proposed fixes without applying them (--dry-run).

  • code(code: str) -> Self

    Apply only the fix for one diagnostic code (--code); repeatable.

#

DartFormatSettings

class
class DartFormatSettings(DartSettings)

Settings for dart format. With no .path() the current directory is formatted: dart format itself would read stdin instead, and in CI — no terminal, empty stdin — a .setExitIfChanged() check would pass vacuously.

  • path(path: str) -> Self

    A file or directory to format (defaults to .); repeatable.

  • output(mode: Literal['write', 'show', 'json', 'none']) -> Self

    What to do with formatted code: write (default), show, json or none (--output).

  • set_exit_if_changed() -> Self

    Exit with code 1 when any file would change — the CI check (--set-exit-if-changed).

  • line_length(columns: float) -> Self

    Wrap lines longer than this (--line-length).

  • show(which: Literal['all', 'changed', 'none']) -> Self

    Which files to list: all, changed (default) or none (--show).

  • summary(kind: Literal['line', 'profile', 'none']) -> Self

    The summary to print: line (default), profile or none (--summary).

  • follow_links() -> Self

    Follow symbolic links into directories (--follow-links).

  • language_version(version: str) -> Self

    The language version to parse as, e.g. 3.3 (--language-version).

  • enable_experiment(name: str) -> Self

    Enable an experimental language feature (--enable-experiment); repeatable.

#

DartInfoSettings

class
class DartInfoSettings(DartSettings)

Settings for dart info, which prints diagnostic details about the SDK.

  • no_remove_file_paths() -> Self

    Keep file paths in the output instead of redacting them (--no-remove-file-paths).

#

DartPubDepsSettings

class
class DartPubDepsSettings(DartSettings)

Settings for dart pub deps.

  • style(name: Literal['compact', 'tree', 'list']) -> Self

    The layout: compact, tree (default) or list (--style).

  • no_dev() -> Self

    Leave dev dependencies out (--no-dev).

  • executables() -> Self

    List the executables the dependencies expose instead (--executables).

  • json() -> Self

    Print the dependency graph as JSON (--json).

#

DartPubDowngradeSettings

class
class DartPubDowngradeSettings(DartSettings)

Settings for dart pub downgrade.

  • package(name: str) -> Self

    Downgrade only this package (defaults to all); repeatable.

  • offline() -> Self

    Resolve from the local pub cache only (--offline).

  • dry_run() -> Self

    Report what would change without changing it (--dry-run).

  • tighten() -> Self

    Lower the constraints in pubspec.yaml to the resolved versions (--tighten).

#

DartPubGetSettings

class
class DartPubGetSettings(DartSettings)

Settings for dart pub get.

  • offline() -> Self

    Resolve from the local pub cache only (--offline).

  • enforce_lockfile() -> Self

    Fail rather than change pubspec.lock (--enforce-lockfile).

  • dry_run() -> Self

    Report what would change without changing it (--dry-run).

  • no_precompile() -> Self

    Skip precompiling executables (--no-precompile).

#

DartPubOutdatedSettings

class
class DartPubOutdatedSettings(DartSettings)

Settings for dart pub outdated.

  • json() -> Self

    Print machine-readable JSON (--json).

  • show_all() -> Self

    Include packages that are already up to date (--show-all).

  • no_dev_dependencies() -> Self

    Leave dev dependencies out (--no-dev-dependencies).

  • no_transitive() -> Self

    Leave transitive dependencies out (--no-transitive).

  • prereleases() -> Self

    Include prereleases when looking for newer versions (--prereleases).

#

DartPubPackagesSettings

class
class DartPubPackagesSettings(DartSettings)

Settings for dart pub add and dart pub remove.

  • package(spec: str) -> Self

    A package to add or remove; repeatable, at least one is required. For add it takes pub's descriptor syntax: http, http:^1.2.0, or dev:mocktail for a dev dependency.

  • offline() -> Self

    Resolve from the local pub cache only (--offline).

  • dry_run() -> Self

    Report what would change without changing it (--dry-run).

#

DartPubPublishSettings

class
class DartPubPublishSettings(DartSettings)

Settings for dart pub publish.

  • dry_run() -> Self

    Validate the package without uploading it (--dry-run).

  • force() -> Self

    Publish without the confirmation prompt — what CI needs (--force).

  • skip_validation() -> Self

    Publish even when validation reports warnings (--skip-validation).

#

DartPubUpgradeSettings

class
class DartPubUpgradeSettings(DartSettings)

Settings for dart pub upgrade.

  • package(name: str) -> Self

    Upgrade only this package (defaults to all); repeatable.

  • offline() -> Self

    Resolve from the local pub cache only (--offline).

  • dry_run() -> Self

    Report what would change without changing it (--dry-run).

  • major_versions() -> Self

    Also raise constraints in pubspec.yaml across majors (--major-versions).

  • tighten() -> Self

    Raise lower bounds in pubspec.yaml to the resolved versions (--tighten).

  • unlock_transitive() -> Self

    Also upgrade the transitive dependencies of the named packages (--unlock-transitive).

#

DartRunSettings

class
class DartRunSettings(DartVmSettings)

Settings for dart run. The entry point is the last token the settings build, so anything passed through .args() lands after it and reaches the program, not the VM — without an .entry(), the first .args() token is what dart run takes as the program, exactly as on the command line.

  • entry(file_or_target: str) -> Self

    The Dart file to run, or a package executable such as build_runner or test:test. Without one, dart run runs the current package's own executable.

  • observe(bind: str | None=None) -> Self

    Start the VM service with the debugging conveniences and pause on start (--observe=<port>[/<bind-address>]). The value is attached with = because dart run reads the option's value from the next token, which would otherwise be the entry point.

  • enable_vm_service(bind: str | None=None) -> Self

    Start the VM service without pausing (--enable-vm-service=<port>[/<bind-address>]).

#

DartSettings

class
class DartSettings(ToolSettings)

Base for all dart settings: the binary is dart, found on PATH.

#

DartTasks

class
class DartTasks

Typed task functions for the dart CLI.

  • static async analyze(ctx: ServiceContext, configure: Callable[[DartAnalyzeSettings], DartAnalyzeSettings] | None=None) -> ExecResult

    Analyze the project's Dart code: dart analyze.

  • static async format(ctx: ServiceContext, configure: Callable[[DartFormatSettings], DartFormatSettings] | None=None) -> ExecResult

    Format Dart code, or check it with .setExitIfChanged(): dart format.

  • static async fix(ctx: ServiceContext, configure: Callable[[DartFixSettings], DartFixSettings] | None=None) -> ExecResult

    Apply analyzer fixes: dart fix.

  • static async test(ctx: ServiceContext, configure: Callable[[DartTestSettings], DartTestSettings] | None=None) -> ExecResult

    Run the tests: dart test.

  • static async run(ctx: ServiceContext, configure: Callable[[DartRunSettings], DartRunSettings] | None=None) -> ExecResult

    Run a Dart program or package executable: dart run.

  • static async doc(ctx: ServiceContext, configure: Callable[[DartDocSettings], DartDocSettings] | None=None) -> ExecResult

    Generate API documentation: dart doc.

  • static async create(ctx: ServiceContext, configure: Callable[[DartCreateSettings], DartCreateSettings]) -> ExecResult

    Scaffold a project: dart create.

  • static async pub_get(ctx: ServiceContext, configure: Callable[[DartPubGetSettings], DartPubGetSettings] | None=None) -> ExecResult

    Resolve dependencies: dart pub get.

  • static async pub_upgrade(ctx: ServiceContext, configure: Callable[[DartPubUpgradeSettings], DartPubUpgradeSettings] | None=None) -> ExecResult

    Upgrade dependencies: dart pub upgrade.

  • static async pub_downgrade(ctx: ServiceContext, configure: Callable[[DartPubDowngradeSettings], DartPubDowngradeSettings] | None=None) -> ExecResult

    Downgrade dependencies to their lowest allowed versions: dart pub downgrade.

  • static async pub_outdated(ctx: ServiceContext, configure: Callable[[DartPubOutdatedSettings], DartPubOutdatedSettings] | None=None) -> ExecResult

    List outdated dependencies: dart pub outdated.

  • static async pub_deps(ctx: ServiceContext, configure: Callable[[DartPubDepsSettings], DartPubDepsSettings] | None=None) -> ExecResult

    Print the dependency graph: dart pub deps.

  • static async pub_add(ctx: ServiceContext, configure: Callable[[DartPubPackagesSettings], DartPubPackagesSettings]) -> ExecResult

    Add dependencies to pubspec.yaml: dart pub add.

  • static async pub_remove(ctx: ServiceContext, configure: Callable[[DartPubPackagesSettings], DartPubPackagesSettings]) -> ExecResult

    Remove dependencies from pubspec.yaml: dart pub remove.

  • static async pub_publish(ctx: ServiceContext, configure: Callable[[DartPubPublishSettings], DartPubPublishSettings] | None=None) -> ExecResult

    Publish the package to pub.dev: dart pub publish.

  • static async info(ctx: ServiceContext, configure: Callable[[DartInfoSettings], DartInfoSettings] | None=None) -> ExecResult

    Print diagnostic details about the SDK: dart info.

  • static async version(ctx: ServiceContext, configure: Callable[[DartVersionSettings], DartVersionSettings] | None=None) -> ExecResult

    Print the Dart SDK version: dart --version.

#

DartTestSettings

class
class DartTestSettings(DartSettings)

Settings for dart test.

  • path(path: str) -> Self

    A test file or directory to run (defaults to test/); repeatable.

  • name(pattern: str) -> Self

    Run only tests whose name matches a regular expression (--name); repeatable.

  • plain_name(text: str) -> Self

    Run only tests whose name contains a string (--plain-name); repeatable.

  • tags(expression: str) -> Self

    Run only tests with a tag expression (--tags).

  • exclude_tags(expression: str) -> Self

    Skip tests matching a tag expression (--exclude-tags).

  • preset(name: str) -> Self

    Apply a preset from dart_test.yaml (--preset); repeatable.

  • run_skipped() -> Self

    Run skipped tests too (--run-skipped).

  • fail_fast() -> Self

    Stop after the first failure (--fail-fast).

  • platform(name: str) -> Self

    Run on a platform, e.g. vm, chrome or node (--platform); repeatable.

  • compiler(name: str) -> Self

    The compiler for a platform, e.g. dart2js, dart2wasm or kernel (--compiler); repeatable.

  • concurrency(count: float) -> Self

    How many test suites to run at once (--concurrency).

  • timeout(value: str) -> Self

    The default per-test timeout, e.g. 30s or 2x (--timeout).

  • coverage(dir: str) -> Self

    Collect coverage into a directory of JSON reports (--coverage).

  • reporter(name: str) -> Self

    The console reporter: compact, expanded, failures-only, github, json or silent (--reporter).

  • file_reporter(spec: str) -> Self

    Also write a reporter's output to a file, e.g. json:report.json (--file-reporter).

  • randomize_ordering_seed(seed: str | float) -> Self

    Shuffle test order with a seed, or random (--test-randomize-ordering-seed).

  • ignore_timeouts() -> Self

    Do not stop a test at its timeout (--ignore-timeouts).

  • no_color() -> Self

    Print stack traces without colour codes (--no-color).

  • shard(index: float, total: float) -> Self

    Run one shard of the suite: shard(index, total) renders --total-shards total --shard-index index, with index from 0.

#

DartVersionSettings

class
class DartVersionSettings(DartSettings)

Settings for dart --version.

#

DartVmSettings

class
class DartVmSettings(DartSettings)

Flags shared by the commands that load Dart code into the VM — compile and run: --define, --enable-asserts, --enable-experiment, --packages and --verbosity. Valued options render as --flag=value: dart compile js hands its argv to dart2js, whose parser accepts only that spelling, and Dart's args package accepts it everywhere else.

  • define(name: str, value: str) -> Self

    Define an environment declaration (--define=name=value); repeatable.

  • enable_asserts() -> Self

    Enable assert statements (--enable-asserts).

  • enable_experiment(name: str) -> Self

    Enable an experimental language feature (--enable-experiment); repeatable.

  • packages(path: str) -> Self

    The package resolution file to use (--packages).

  • verbosity(level: Literal['error', 'warning', 'info', 'all']) -> Self

    How much to print: error, warning, info or all (--verbosity).