InMemoryBuildStep class

An in-memory implementation of BuildStep used by tests.

Instead of writing outputs to disk or a build cache this class captures the last written output as a StringAsset in output. This simplifies assertions in tests that need to verify generated content. The build step is constructed with generateToCache: false so it won't attempt to update any external cache.

Inheritance
Annotations
  • @visibleForTesting

Constructors

InMemoryBuildStep(Asset asset, Resolver resolver, {required Set<String> allowedExtensions})
Creates an InMemoryBuildStep for the given asset and resolver.

Properties

allowedExtensions → Set<String>
The set of allowed file extensions for output assets.
finalinherited
asset → Asset
The primary input for this build step.
finalinherited
generateToCache → bool
Whether to write outputs to the build cache instead of alongside inputs.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
library → LibraryElement
The resolved LibraryElement for the build step's input asset.
no setter
output ↔ StringAsset?
The last asset written by this build step as a StringAsset.
getter/setter pair
outputs → Set<Uri>
The set of output URIs that have been written by this build step.
no setterinherited
resolver → Resolver
The Resolver for this build step.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

findAssets(PathMatcher matcher, {String? subDir}) → List<Asset>
Finds assets within the root package that match the matcher pattern.
inherited
getOutputUri(String extension) → Uri
Resolves the output URI for a file with the given extension.
inherited
hasValidPartDirectiveFor(String extension) → bool
Returns true if the input library has a part directive for the given extension.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
writeAsBytes(List<int> bytes, {required String extension}) → FutureOr<void>
Writes bytes to the in-memory output and records the resulting StringAsset in output.
override
writeAsString(String contents, {required String extension, Encoding encoding = utf8}) → FutureOr<void>
Writes contents to the in-memory output and records the resulting StringAsset in output.
override

Operators

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