Reputation: 17360
in my application i have this variable:
List<Likers> likers = mediaOrAd.likers;
and i would like to make this design like with this layout:
for this code i get error and it's not correct:
_buildFeedLikers(Feeds mediaOrAd) {
List<Likers> likers = mediaOrAd.likers;
double fromRight = 0;
if (likers != null && likers.length > 0) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Stack(
children: <Widget>[
...List.generate(likers.length, (liker) {
fromRight = fromRight + 10;
return Positioned(
top: 0.0,
right: fromRight,
child: AvatarWidget(
imageUrl: likers[liker].profilePicUrl,
),
);
})
],
)
],
);
} else {
return Container();
}
}
this widget should be place in this tree:
Expanded
ListView.builder
Container
Card
ExpandableNotifier
ScrollOnExpand
Column
Upvotes: 2
Views: 120
Reputation: 268384
This is for your updated post:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Stack(
children: <Widget>[
Container(
child: Container(
child: Column(
children: <Widget>[
Expanded(
child: ListView(
children: <Widget>[
Container(
child: Card(
child: Column(
children: <Widget>[
SizedBox(
height: 56,
child: Stack(
children: List.generate(
5,
(i) => Positioned(
right: i * 30.0,
child: ClipOval(
child: Container(
width: 56,
height: 56,
color: Colors.blue[(i * 100) % 900],
),
),
),
),
),
),
],
),
),
)
],
),
),
],
),
),
),
],
),
);
}
Upvotes: 2
Reputation: 268384
Output:
Code:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Stack(
children: List.generate(
5,
(i) => Positioned(
right: i * 30.0,
child: ClipOval(
child: Container(
width: 56,
height: 56,
color: Colors.blue[(i * 100) % 900],
),
),
),
).toList(),
),
);
}
Upvotes: 3