flutter 使用AnimatedBuilder的PageTransition返回黑屏

r7knjye2  于 2023-06-30  发布在  Flutter
关注(0)|答案(1)|浏览(153)

我得到一个黑屏'PageRouteBuilder',我不知道为什么。我希望有人能给我点线索

Navigator.of(context).push(
        PageRouteBuilder(pageBuilder: (context, animation, secondAnimation) {
      return TestPage();
    }, transitionsBuilder: (context, animation, secondAnimation, child) {
      return AnimatedBuilder(
          animation: _animationController,
          builder: (context, child) {
            return Transform(
              alignment: FractionalOffset.center,
              transform: Matrix4.identity()
                ..setEntry(3, 2, 0.002)
                ..rotateY(3.14 * _animation.value),
              child: child,
            );
          });
    }));
kcwpcxri

kcwpcxri1#

Transform小部件从AnimatedBuilder获取子级,但它没有子级。只需将transitionsBuilder的子参数传递给AnimatedBuilder构造函数或重命名AnimatedBuilder的子参数。

return AnimatedBuilder(
      animation: _animationController,
      builder: (context, _) {
        return Transform(
          alignment: FractionalOffset.center,
          transform: Matrix4.identity()
            ..setEntry(3, 2, 0.002)
            ..rotateY(3.14 * _animation.value),
          child: child,
        );
      });

相关问题