copy method

  1. @override
Future<void> copy(
  1. String destinationPath
)
override

Copies animation.

Implementation

@override
Future<void> copy(String destinationPath) async {
  assert(destinationPath.isNotEmpty);

  print('\n--copy'
      '\n\tsource: `$sourcePath`'
      '\n\tdestinationPath: `$destinationPath`'
      '\n');

  final destination = Directory(destinationPath);

  // 1) Clear destination path.
  var step = 1;
  resetCurrentIndent();
  {
    print('$currentIndent$step) Clearing destination path'
        ' `${destination.path}`...');
    if (destination.existsSync()) {
      destination.deleteSync(recursive: true);
    }
    print('$currentIndent\tSuccess clear destination path'
        ' `${destination.path}`.');
  }

  // 2) Copy files.
  ++step;
  resetCurrentIndent();
  {
    print('$currentIndent$step) Copying animation'
        ' from `${current.path}` to `${destination.path}`...');
    increaseCurrentIndent();
    _copyWithRenameFiles(current, destination);
    decreaseCurrentIndent();
    current = destination;
    print('$currentIndent\tSuccess copy animation'
        ' from `${current.path}` to `${destination.path}`.');
  }

  // 3) Rename dependencies into the file [fileAtlas].
  ++step;
  resetCurrentIndent();
  {
    final p = '${current.path}/$fileAtlas';
    print('$currentIndent$step) Renaming dependencies into the file `$p`...');
    final oldFilePattern = buildFileNameTexture(sourceFolder);
    final newFilePattern = buildFileNameTexture(currentFolder);
    final file = File(p);
    increaseCurrentIndent();
    _renameContentFile(file, oldFilePattern, newFilePattern);
    decreaseCurrentIndent();
    print('$currentIndent\tSuccess rename dependencies into the file `$p`.');
  }
}