将android的launch_background缩放比例与抖动的Image.asset匹配的最佳方法是什么?

时间:2019-04-14 13:45:33

标签: flutter-image

我正在尝试创建一个从启动器初始屏幕到颤动初始动画的平滑过渡。

要获得与第一帧相匹配的图像大小,需要先了解设备像素的比率-但是,执行MediaQuery.of()会延迟抖动图像,从而导致启动器图像与抖动Image.asset()之间发生闪烁。

有没有办法延迟启动器启动画面? 还是捕获它而不是再次加载图像? 或以其他方式获取devicePixelRatio?

谢谢

 Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        widget.child,
        IgnorePointer(
          child: Transform.scale(
            scale: _scale,
            alignment: Alignment.center,
            child: Image.asset(
              "assets/images/splash.png",
              fit: BoxFit.none,
              filterQuality: FilterQuality.low,
              color: Color.fromRGBO(255, 255, 255, _opacity),
              colorBlendMode: BlendMode.modulate,
              // this needs to be devicePixelRatio to match system splash
              // BUT calling MediaQuery.of(context) here to get this value 
              // delays the image causing a flash... TODO
              scale: 2.6, // MediaQuery.of(context).devicePixelRatio,
              width: double.infinity,
              height: double.infinity,
            ),
          ),
        ),
      ],
    );
  }

0 个答案:

没有答案
相关问题