首页 > 解决方案 > 如何在 Flutter 中转换背景图像?

问题描述

我希望每当我加载我的屏幕时,背景图像都应该放大然后缩小。我怎样才能实现那个 inFlutter?

标签: flutterflutter-animation

解决方案


添加动画页面所需的此 Initstate 代码

  void initState() {
    super.initState();
    animationController = new AnimationController(
        vsync: this, duration: new Duration(seconds: 3));
    animation =
    new CurvedAnimation(parent: animationController, curve: Curves.easeOut);

    animation.addListener(() => this.setState(() {}));
    animationController.forward();

    setState(() {
      _visible = !_visible;
    });
  }

并将其添加到您的图像小部件中

             new Image.asset('assets/images/background.png',
                width: animation.value * 250,
                height: animation.value * 250,
              ),

推荐阅读