flutter 如何更改动画大小?

utugiqy6  于 12个月前  发布在  Flutter
关注(0)|答案(2)|浏览(160)

我已经尝试过覆盖rive动画小部件与许多小部件,但动画仍然保持大,无论我做什么,我怎么能改变动画大小这里是代码

height: 50,
                width: 50,
                child: RiveAnimation.asset(
                  'assets/rave/rotating-crown.riv',
                  fit: BoxFit.scaleDown,
                ),
              ),

字符串
here is the result正如你所看到的,它非常大,我希望它像一个加载指示器非常小
我尝试了像Container、SizedBox、FittedBox这样的小部件,但都没有帮助。

dvtswwa3

dvtswwa31#

我显示它像下面和它为我工作

Container(
 height: 180.0,
 child: Rive(
  artboard: _riveArtboard!,
  fit: BoxFit.scaleDown,
 ),
),

字符串

gk7wooem

gk7wooem2#

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Rive'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Center(
            child: Container(
              height: 80,
              width: 80,
              child: RiveAnimation.asset(
                'assets/avatar.riv',
                fit: BoxFit.scaleDown,
              ),
            ),
          ),
        ],
      ),
    );
  }
}

字符串
输出值:


的数据

相关问题