You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter启动页Logo缩放动画实现及对齐参数位置咨询

解决AnimatedSplashScreen添加对齐参数的问题

你可以通过用Align组件包裹splash内的Column来实现自定义对齐,AnimatedSplashScreen本身没有直接暴露alignment参数,但可以通过嵌套Widget的方式实现:

修改后的代码示例:

return AnimatedSplashScreen(
  backgroundColor: Colors.white,
  splashIconSize: MediaQuery.of(context).size.width,
  // 用Align替代原来的Center,设置你需要的对齐方式
  splash: Align(
    alignment: Alignment.center, // 这里可以改成你要的对齐,比如Alignment.bottomCenter等
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Image.asset(
          'Assets/Animation.gif',
          width: MediaQuery.of(context).size.width*0.5,
        ),
        SizedBox(height: MediaQuery.of(context).size.height*0.02,),
        Image.asset(
          'Assets/text.png',
          width: MediaQuery.of(context).size.width*0.7,
        ),
      ],
    ),
  ),
  animationDuration: Duration(seconds: 3),
  pageTransitionType: PageTransitionType.scale,
  nextScreen: Login(),
);

说明:

  • Align组件的alignment参数可以设置任意你需要的对齐位置,比如Alignment.topLeft、Alignment.bottomRight等,完全满足自定义布局需求。
  • 这种方式不会影响原有缩放动画,因为AnimatedSplashScreen的动画是作用在整个splash Widget上的,Align只是调整内容的位置。

内容的提问来源于stack exchange,提问作者ahmad fakher

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 06:32:42