removeAnimation method

  1. @override
Future<void> removeAnimation(
  1. String name
)
override

Removes animation with name.

Implementation

@override
Future<void> removeAnimation(String name) async {
  assert(name.isNotEmpty);

  print('\n--remove_animation'
      '\n\tsource: `$sourcePath`'
      '\n\tname: $name'
      '\n');

  // 1) Search animation.
  var step = 1;
  resetCurrentIndent();
  late final JsonMap animations;
  {
    final p = pathToFileSkeleton;
    print(
        '$currentIndent$step) Searching animation `$name` into the `$p`...');

    final file = File(p);
    final skeleton = SpineSkeletonJson(file);
    animations =
        (skeleton.json['animations'] ?? <String, dynamic>{}) as JsonMap;

    if (animations.isEmpty) {
      print('$currentIndent\tAnimation `$name` not found into the `$p`.');
      return;
    }

    print('$currentIndent\tAnimation `$name` found into the `$p`.');
  }

  // 2) Remove animation.
  ++step;
  resetCurrentIndent();
  {
    final p = pathToFileSkeleton;
    print('$currentIndent$step) Removing animation `$name` from the `$p`...');

    final file = File(p);
    final skeleton = SpineSkeletonJson(file);
    final removed = skeleton.removeAnimation(name);
    skeleton.save(removed);

    print('$currentIndent\tAnimation `$name` removed from the `$p`.');
  }
}