一、将图片处理成黑白图片
//第一种方法CachedNetworkImage(imageUrl: imageUrl,width: 80,height: 80,fit: BoxFit.cover,color: Colors.black,//目标颜色colorBlendMode: BlendMode.color,//颜色混合模式)//第二种方法ShaderMask(shaderCallback: (Rect bounds) {return LinearGradient(colors: [Colors.black, Colors.white]).createShader(bounds);},blendMode: BlendMode.color,child: CachedNetworkImage(imageUrl: imageUrl,width: 80,height: 80,fit: BoxFit.cover),)
二、将Container的背景图片处理成黑白图片
Container(width: 200,height: 200,decoration: BoxDecoration(image: DecorationImage(image: NetworkImage("https://upload-images.jianshu.io/upload_images/5809200-a99419bb94924e6d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"),fit: BoxFit.cover,colorFilter:const ColorFilter.mode(Colors.black, BlendMode.color),),),child: Center(child: MyText.bodyMedium("Container背景图片",color: Colors.pink, fontWeight: 700),),)