discontinuedPackage fluttersdk_artisan has been discontinued and replaced by dowel.

InstallTransaction class

Orchestrator that stages a list of InstallOperations and either applies them atomically to disk, renders a dry-run preview, or refuses to write when ConflictDetector flags a target file the user has modified out-of-band.

Commit semantics are all-or-nothing:

  1. Every file write lands on <absPath>.tmp first via InstallContext.fs.
  2. Only after every .tmp write succeeds do the renames + deletes apply.
  3. If any .tmp write throws, every staged .tmp is removed and the method returns an Error with rolledBack: true.

One-shot: each InstallTransaction instance commits exactly once. A second commit throws StateError so callers cannot replay operations against stale state.

Usage

final tx = InstallTransaction(ctx, pluginName: 'firebase_messaging');
tx.stage(const WriteFile(targetPath: 'lib/config/firebase.dart', content: '...'));
tx.stage(const InjectImport(targetFile: 'lib/main.dart', importStatement: "..."));

final result = await tx.commit();
switch (result) {
  case Success(:final opCount, :final recordPath):
    ctx.artisanContext.output.success('Installed $opCount ops; record: $recordPath');
  case DryRun(:final opCount):
    ctx.artisanContext.output.info('Previewed $opCount ops; nothing written');
  case Conflict(:final conflicts):
    ctx.artisanContext.output.warning('${conflicts.length} conflicts; pass --force to override');
  case Error(:final error, :final rolledBack):
    ctx.artisanContext.output.error('Failed: $error (rolled back: $rolledBack)');
}

Constructors

InstallTransaction(InstallContext ctx, {required String pluginName})
Creates a transaction bound to ctx for the plugin identified by pluginName. The plugin name threads into the .artisan/installed/<pluginName>.json record path written on success.

Properties

hashCode → int
The hash code for this object.
no setterinherited
pendingCount → int
Number of operations staged but not yet committed.
no setter
pendingOps → List<InstallOperation>
Read-only view of the staged operations in insertion order. Mutating the returned list throws UnsupportedError.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

commit({bool dryRun = false, bool force = false}) → Future<TransactionResult>
Executes the staged operations.
debugSetConflictsForTest(List<FileConflict> conflicts) → void
Test-only seam (will be removed once Step 7's ConflictDetector is wired): pre-populates the conflict list returned by _detectConflicts.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stage(InstallOperation op) → void
Appends op to the staged operation queue.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited