【问题标题】:Size for image asset not changing in Animated Splash Screen动画启动画面中图像资源的大小不变
【发布时间】:2021-11-14 05:52:11
【问题描述】:

我正在尝试为应用创建动画启动画面。我已经使用 Image.asset() 在初始屏幕中插入了一个图像,但是当我输入任何高度或宽度数字时,图像根本不会改变。它仍然很小,但我希望它更大。

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: AnimatedSplashScreen(
          duration: 4000,
          splash:
          Image.asset("assets/icons/icon.png",
            height: 200),
          nextScreen: Homepage(title: "Travel Nepal",),
          splashTransition: SplashTransition.fadeTransition,
          backgroundColor: Color(0xffF99DC8),
      ),
    );
  }
}

图片尺寸:

我也使用了“fit: BoxFit.fill”属性,但图像会突然变形或被切断。有关如何对此进行更改的任何建议?

【问题讨论】:

    标签: image flutter flutter-animation


    【解决方案1】:

    显然,您可以使用 AimatedSplashScreen 小部件的 splashIconSize 属性。

    https://github.com/clean-code-dev/animated_splash_screen/issues/18

    【讨论】:

    • 嗨!太感谢你了,我的天。我使用 splashIconSize: 200 ,结果很完美。
    【解决方案2】:
    AnimatedSplashScreen(
            duration: 3500,
            splash: 'assets/images/app_logo.png',
            splashIconSize: double.maxFinite,
            nextScreen: CompanyList(),
            centered: true,
            splashTransition: SplashTransition.rotationTransition,
            backgroundColor: Colors.white),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      相关资源
      最近更新 更多