zuke.tools.flutter

← Python API reference

@zuke/flutter 1.0.0: @zuke/flutter — typed FlutterTasks wrappers for the [Flutter](https://flutter.dev) CLI, for use in Zuke builds: analyze, test, build every artifact, manage pub dependencies, and drive devices and the SDK.

Symbols

#

FlutterAnalyzeSettings

class
class FlutterAnalyzeSettings(FlutterSettings)

Settings for flutter analyze.

  • path(path: str) -> Self

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

  • no_fatal_infos() -> Self

    Do not fail on info-level issues (--no-fatal-infos).

  • no_fatal_warnings() -> Self

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

  • write(path: str) -> Self

    Also write the analysis results to a file (--write).

#

FlutterAppSettings

class
class FlutterAppSettings(FlutterCompileSettings)

Compile flags plus the build mode and the entry point (--target), shared by flutter build and flutter drive.

  • mode(mode: Literal['debug', 'profile', 'release']) -> Self

    The build mode (--debug, --profile or --release).

  • release() -> Self

    Build in release mode (--release).

  • target(path: str) -> Self

    The main entry-point file, instead of lib/main.dart (--target).

#

FlutterCommandSettings

class
class FlutterCommandSettings(FlutterSettings)

Settings for a flagless command: flutter clean, or flutter gen-l10n (configured by l10n.yaml). Extra flags go through .args().

#

FlutterCompileSettings

class
class FlutterCompileSettings(FlutterSettings)

Flags shared by the commands that compile Dart code: --no-pub, --dart-define, --dart-define-from-file and --flavor.

  • no_pub() -> Self

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

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

    Define a compile-time constant (--dart-define=name=value); repeatable.

  • dart_define_from_file(path: str) -> Self

    Read compile-time constants from a JSON or .env file (--dart-define-from-file); repeatable.

  • flavor(name: str) -> Self

    The build flavor, for apps with product flavors or schemes (--flavor).

#

FlutterConfigSettings

class
class FlutterConfigSettings(FlutterSettings)

Settings for flutter config.

  • enable(feature: str) -> Self

    Turn a feature on, e.g. web → --enable-web; repeatable.

  • disable(feature: str) -> Self

    Turn a feature off, e.g. web → --no-enable-web; repeatable.

  • android_sdk(dir: str) -> Self

    The Android SDK directory (--android-sdk).

  • no_analytics() -> Self

    Turn analytics reporting off (--no-analytics).

  • clear_features() -> Self

    Reset every feature flag to its default (--clear-features).

#

FlutterCreateSettings

class
class FlutterCreateSettings(FlutterSettings)

Settings for flutter create.

  • dir(path: str) -> Self

    The directory to create the project in; required.

  • org(org: str) -> Self

    The reverse-domain organization, e.g. com.example (--org).

  • project_name(name: str) -> Self

    The Dart package name, instead of the directory's (--project-name).

  • description(text: str) -> Self

    The project description (--description).

  • template(name: str) -> Self

    The template: app, module, package, plugin, … (--template).

  • platform(name: str) -> Self

    A platform to scaffold, e.g. android or web (--platforms); repeatable.

  • empty() -> Self

    Scaffold a minimal app without the counter sample (--empty).

#

FlutterDevicesSettings

class
class FlutterDevicesSettings(FlutterSettings)

Settings for flutter devices.

  • machine() -> Self

    Print the devices as JSON (--machine).

#

FlutterDoctorSettings

class
class FlutterDoctorSettings(FlutterSettings)

Settings for flutter doctor.

  • verbose() -> Self

    Show full details for every check (--verbose).

#

FlutterDriveSettings

class
class FlutterDriveSettings(FlutterAppSettings)

Settings for flutter drive, which runs integration tests on a device.

  • driver(path: str) -> Self

    The test driver file, e.g. test_driver/integration_test.dart (--driver).

  • device_id(id: str) -> Self

    The device to run on, e.g. chrome or an emulator id (--device-id).

  • screenshot(dir: str) -> Self

    Save a screenshot to this directory if the run fails (--screenshot).

#

FlutterInstallSettings

class
class FlutterInstallSettings(FlutterSettings)

Settings for flutter install, which installs a built app on a device.

  • mode(mode: Literal['debug', 'profile', 'release']) -> Self

    Install the build of this mode (--debug, --profile or --release).

  • flavor(name: str) -> Self

    Install this build flavor (--flavor).

  • device_id(id: str) -> Self

    The device to install on (--device-id).

  • use_application_binary(path: str) -> Self

    Install this prebuilt binary instead (--use-application-binary).

  • uninstall_only() -> Self

    Only uninstall the app (--uninstall-only).

#

FlutterPrecacheSettings

class
class FlutterPrecacheSettings(FlutterSettings)

Settings for flutter precache, which downloads platform artifacts.

  • platform(name: str) -> Self

    Fetch a platform's artifacts, e.g. android → --android; repeatable.

  • force() -> Self

    Re-download even when cached (--force).

#

FlutterPubDepsSettings

class
class FlutterPubDepsSettings(FlutterSettings)

Settings for flutter pub deps.

  • json() -> Self

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

#

FlutterPubGetSettings

class
class FlutterPubGetSettings(FlutterSettings)

Settings for flutter pub get.

  • offline() -> Self

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

  • enforce_lockfile() -> Self

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

#

FlutterPubOutdatedSettings

class
class FlutterPubOutdatedSettings(FlutterSettings)

Settings for flutter pub outdated.

  • json() -> Self

    Print machine-readable JSON (--json).

  • show_all() -> Self

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

#

FlutterPubPackagesSettings

class
class FlutterPubPackagesSettings(FlutterSettings)

Settings for flutter pub add and flutter 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.

#

FlutterPubUpgradeSettings

class
class FlutterPubUpgradeSettings(FlutterSettings)

Settings for flutter pub upgrade.

  • package(name: str) -> Self

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

  • 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).

#

FlutterSettings

class
class FlutterSettings(ToolSettings)

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

#

FlutterTasks

class
class FlutterTasks

Typed task functions for the flutter CLI.

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

    Analyze the project's Dart code: flutter analyze.

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

    Run the unit and widget tests: flutter test.

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

    Resolve dependencies: flutter pub get.

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

    Upgrade dependencies: flutter pub upgrade.

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

    List outdated dependencies: flutter pub outdated.

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

    Print the dependency graph: flutter pub deps.

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

    Add dependencies to pubspec.yaml: flutter pub add.

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

    Remove dependencies from pubspec.yaml: flutter pub remove.

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

    Delete the build and .dart_tool directories: flutter clean.

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

    Scaffold a project: flutter create.

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

    Generate localizations from l10n.yaml: flutter gen-l10n.

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

    Run integration tests on a device: flutter drive.

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

    Install a built app on a device: flutter install.

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

    List connected devices: flutter devices.

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

    Check the toolchain: flutter doctor.

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

    Download platform artifacts: flutter precache.

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

    Change SDK settings: flutter config.

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

    Print the Flutter, Dart and engine versions: flutter --version.

#

FlutterTestSettings

class
class FlutterTestSettings(FlutterCompileSettings)

Settings for flutter test.

  • path(path: str) -> Self

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

  • coverage() -> Self

    Collect coverage into coverage/lcov.info (--coverage).

  • coverage_path(path: str) -> Self

    Where to write the lcov coverage report (--coverage-path).

  • merge_coverage() -> Self

    Merge with the existing coverage report (--merge-coverage).

  • 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).

  • concurrency(count: float) -> Self

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

  • reporter(name: str) -> Self

    The console reporter: compact, expanded, github, json, … (--reporter).

  • file_reporter(spec: str) -> Self

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

  • update_goldens() -> Self

    Rewrite golden files instead of comparing against them (--update-goldens).

  • platform(name: str) -> Self

    Run on a platform other than the VM, e.g. chrome (--platform).

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

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

  • timeout(value: str) -> Self

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

  • 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.

#

FlutterVersionSettings

class
class FlutterVersionSettings(FlutterSettings)

Settings for flutter --version.

  • machine() -> Self

    Print the versions as JSON (--machine).