StringAsset class
A simple in-memory implementation of Asset for testing purposes.
- Implemented types
- Annotations
-
- @visibleForTesting
Constructors
- StringAsset(String content, {String fileName = 'path.dart'})
-
Creates a new StringAsset with the given
contentand optionalfileName. - StringAsset.withRawUri(String content, String stringUri)
-
Creates a new StringAsset with the given
contentandstringUri.
Properties
- content → String
-
The content of this asset as a string.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
A unique identifier for this asset.
it's typically a hash of the asset's shortUri.
latefinal
- packageName → String?
-
Extracts the package name from the shortUri.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shortUri → Uri
-
A shortened URI that may use package or asset schemes.
no setteroverride
- stringUri → String
-
The URI string representing this asset.
final
- uri → Uri
-
The complete URI that points to this asset.
no setteroverride
Methods
-
existsSync(
) → bool -
Checks whether the asset exists.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readAsBytesSync(
) → Uint8List -
Reads the entire asset synchronously as a list of bytes.
override
-
readAsStringSync(
{Encoding encoding = utf8}) → String -
Reads the entire asset synchronously as a string.
override
-
safeDelete(
) → void -
Safely deletes the asset if it exists.
override
-
toJson(
) → Map< String, dynamic> -
Converts this asset to a JSON representation.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
uriWithExtension(
String ext) → Uri -
Creates a new URI with the same path as this asset but with a different extension.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- testPackageName → const String
- The package name used for test assets.