FadeInImage(每日Flutter 小部件)

FadeInImage.assetNetwork({
    Key key,
    @required String placeholder,//
    @required String image,
    AssetBundle bundle,
    double placeholderScale,
    double imageScale = 1.0,
    this.excludeFromSemantics = false,
    this.imageSemanticLabel,
    this.placeholderSemanticLabel,
    this.fadeOutDuration = const Duration(milliseconds: 300),//控制placeholder的淡出动画时间
    this.fadeOutCurve = Curves.easeOut,//控制placeholder的淡出动画方式
    this.fadeInDuration = const Duration(milliseconds: 700),//控制目标图像的淡入动画时间
    this.fadeInCurve = Curves.easeIn,//控制目标图像的淡入动画方式
    this.width,
    this.height,
    this.fit,
    this.alignment = Alignment.center,
    this.repeat = ImageRepeat.noRepeat,
    this.matchTextDirection = false,
    })
 */

  

有默认占位图和淡入效果

例子

class FadeInImageWidgetState extends State<StatefulWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Center(
        child: FadeInImage.assetNetwork(
            placeholder: "assets/images/app_loading.png",
            fadeOutDuration: Duration(milliseconds: 3000),
            fadeOutCurve: Curves.easeOut,
            image:
                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584502838493&di=a911bd87ead27d565adafde13d8c5cef&imgtype=0&src=http%3A%2F%2Fa0.att.hudong.com%2F78%2F52%2F01200000123847134434529793168.jpg"),
      ),
    );
  }
}

  

原文地址:https://www.cnblogs.com/wjw334/p/12515382.html