[英]Any Circle images overlapping plugin in Flutter
Or you can use Align inside of ListView();
或者您可以在ListView();
中使用 Align widget小部件
Widget _stackedHeads() => Container(
width: double.infinity,
height: 100,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 4,
itemBuilder: (context, index) {
return Align(
widthFactor: 0.6,
child: CircleAvatar(
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 18,
backgroundImage: NetworkImage(
'https://www.jessleewong.com/wp-content/uploads/2019/12/jessleewong_20191109_3.jpg'), // Provide your custom image
),
),
);
}));
cames in handy when your content is dynamic, in that code in Align();
当您的内容是动态的时,在Align();
widget property widthFactor:
determines how much in horizontal they should overlap.小部件属性widthFactor:
确定它们应该在水平方向上重叠多少。
There is no plugin but you can make a custom one using circle avatars(with white border) in a stack.没有插件,但您可以使用堆栈中的圆形头像(带白色边框)制作自定义插件。
class CustomAvatars extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: 80,
height: 40,
color: Colors.white,
child: Stack(
children: <Widget>[
Align(
alignment: Alignment.centerRight,
child: CircleAvatar(
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 18,
backgroundColor: Colors.red,
child: Image.asset('assets\image'), // Provide your custom image
),
),
),
Align(
alignment: Alignment.center,
child: CircleAvatar(
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 18,
backgroundColor: Colors.red,
child: Image.asset('assets\image'), // Provide your custom image
),
),
),
Align(
alignment: Alignment.centerLeft,
child: CircleAvatar(
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 18,
backgroundColor: Colors.red,
child: Image.asset('assets\image'), // Provide your custom image
),
),
),
],
),
);
}
}
There is no plugin but you can make a custom one using circle avatars and positioned in a stack.没有插件,但您可以使用圆形头像制作自定义插件并放置在堆栈中。
import 'package:flutter/material.dart';
class CustomAvatar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: 80,
height: 40,
color: Colors.white,
child: Stack(
children: <Widget>[
Positioned(
left: 0,
child: CircleAvatar(
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 18,
backgroundColor: Colors.red,
child: Image.asset('assets\image'), // Provide your custom image
),
),
),
Positioned(
left: 8,
child: CircleAvatar(
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 18,
backgroundColor: Colors.red,
child: Image.asset('assets\image'), // Provide your custom image
),
),
),
Positioned(
left: 16,
child: CircleAvatar(
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 18,
backgroundColor: Colors.red,
child: Image.asset('assets\image'), // Provide your custom image
),
),
),
],
),
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.