copyFromAssets static method

Future<void> copyFromAssets(
  1. String assetsPath,
  2. String destinationPath
)

Implementation

static Future<void> copyFromAssets(
    String assetsPath, String destinationPath) async {
  ByteData data = await rootBundle.load(assetsPath);
  List<int> bytes =
  data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);

  String path = destinationPath;
  if (File(path).existsSync()) {
    File(path).deleteSync();
  }
  await File(path).create();
  await File(path).writeAsBytes(bytes);
}