参数类型 'List<Future<Sprite>>' 无法分配给参数类型 'List<Sprite>'

The argument type 'List<Future<Sprite>>' can't be assigned to the parameter type 'List<Sprite>'

class MyGame extends BaseGame with HasTapableComponents {
  SpriteAnimationComponent girl = SpriteAnimationComponent();

  MyGame();
  @override
  Future<void> onLoad() async {
    final sprites = [0, 1, 2,3,4,5,6,7,8,9]
      .map((i) async => await Sprite.load('Attack__00$i.png'))
      .toList();
    girl = SpriteAnimationComponent(
      animation: SpriteAnimation.spriteList(sprites, stepTime: 0.01),
      size: Vector2.all(100) 
    );
    add(girl);
    print(size);
  }
}

根据github flutter flame 文档实现SpriteAnimationComponent,animation: SpriteAnimation.spriteList(sprites, ...)。正如我注意到的,这里的问题是 sprites 是精灵的未来列表,而 spriteList 需要精灵列表。这是文档中的问题,还是我哪里出错了?

您必须等待未来精灵列表具体化,如下所示:

final sprites = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      .map((i) => Sprite.load('Attack__00$i.png'));
final animation = SpriteAnimation.spriteList(
  await Future.wait(sprites),
  stepTime: 0.01,
);
girl = SpriteAnimationComponent(
  animation: animation,
  size: Vector2.all(100) 
);
add(girl);

编辑:我看到文档中有错误,我会更新它们。