flutter Stack 绝对布局的使用
使用stack 和Positioned
实现绝对布局 进行位置偏移
Container( alignment: Alignment.center, width: double.infinity, child: Stack( clipBehavior: Clip.none, alignment: Alignment.center, children: [ Container( width: 40, height: 40, margin: EdgeInsets.fromLTRB(0, 0, 90, 0), decoration: BoxDecoration( border: Border.all(width: 2,color: Colors.white), borderRadius: BorderRadius.circular(20)), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(20)), child: CachedNetworkImage( //图片缓存 imageUrl: 'http://img.crcz.com/allimg/202002/29/1582979072845574-lp.jpg', progressIndicatorBuilder: (context, url, downloadProgress) => CircularProgressIndicator( value: downloadProgress.progress), errorWidget: (context, url, error) => Icon(Icons.error), ), ), ), Positioned( left: 30, child: Container( width: 40, height: 40, decoration: BoxDecoration( border: Border.all(width: 2,color: Colors.white), borderRadius: BorderRadius.circular(20)), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(20)), child: CachedNetworkImage( //图片缓存 imageUrl: 'https://img2.woyaogexing.com/2021/01/27/76d0ec1087f944d286031185a97ab13b!400x400.jpeg', progressIndicatorBuilder: (context, url, downloadProgress) => CircularProgressIndicator( value: downloadProgress.progress), errorWidget: (context, url, error) => Icon(Icons.error), ), ), ), ), Positioned( left: 60, child: Container( width: 40, height: 40, decoration: BoxDecoration( border: Border.all(width: 2,color: Colors.white), borderRadius: BorderRadius.circular(20)), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(20)), child: CachedNetworkImage( //图片缓存 imageUrl: 'https://img2.woyaogexing.com/2021/01/27/e964deb7eadb437aad814b1ee46a8c50!400x400.jpeg', progressIndicatorBuilder: (context, url, downloadProgress) => CircularProgressIndicator( value: downloadProgress.progress), errorWidget: (context, url, error) => Icon(Icons.error), ), ), ), ), Positioned( left: 90, child: Container( width: 40, height: 40, decoration: BoxDecoration( border: Border.all(width: 2,color: Colors.white), borderRadius: BorderRadius.circular(20)), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(20)), child: CachedNetworkImage( //图片缓存 imageUrl: 'https://img2.woyaogexing.com/2021/01/26/4e4643708cb7430aafecf59574beea5e!400x400.jpeg', progressIndicatorBuilder: (context, url, downloadProgress) => CircularProgressIndicator( value: downloadProgress.progress), errorWidget: (context, url, error) => Icon(Icons.error), ), ), ), ), ], ), ),