copyAssetToTempDir function

Future<String> copyAssetToTempDir({
  1. required String asset,
})

Implementation

Future<String> copyAssetToTempDir({
  required String asset,
}) async {
  // Load the CSV file from assets.

  final ByteData data = await rootBundle.load('assets/$asset');

  // Locate the destination.

  String dest = '$tempDir/${p.basename(asset)}';

  // Create a file in the temp directory.

  final File tempFile = File(dest);

  // Write the CSV file content to the temp file.

  await tempFile.writeAsBytes(data.buffer.asUint8List(), flush: true);

  debugText('  ASSET', dest);

  return dest;
}