generateAssetConstant method

String generateAssetConstant(
  1. Asset asset,
  2. String packagePath
)

Generates a single asset constant definition.

Creates a properly formatted static const field for an individual asset.

Parameters:

  • asset: The asset to generate a constant for
  • packagePath: The package path prefix for the asset

Returns the constant definition as a string.

Implementation

String generateAssetConstant(Asset asset, String packagePath) {
  final constantName = asset.toConstantName();
  final assetPath = '$packagePath/${asset.fileName}';

  return "  static const String $constantName = '$assetPath';";
}