Flutter 颤振设计多个部件相互水平上方

Flutter 颤振设计多个部件相互水平上方,flutter,flutter-layout,Flutter,Flutter Layout,在我的应用程序中,我有一个变量: List<Likers> likers = mediaOrAd.likers; 输出: @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Stack( children: List.generate( 5, (i) => Positioned(

在我的应用程序中,我有一个变量:

List<Likers> likers = mediaOrAd.likers;

输出:

@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(),
    ),
  );
}


代码:

@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(),
    ),
  );
}

这是为您更新的帖子:

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],
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    ),
  );
}
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(),
主体:堆栈(
儿童:[
容器(
子:容器(
子:列(
儿童:[
扩大(
子:ListView(
儿童:[
容器(
孩子:卡片(
子:列(
儿童:[
大小盒子(
身高:56,
子:堆栈(
子项:List.generate(
5.
(i) =>定位(
右:i*30.0,
孩子:斜坡(
子:容器(
宽度:56,
身高:56,
颜色:颜色。蓝色[(i*100)%900],
),
),
),
),
),
),
],
),
),
)
],
),
),
],
),
),
),
],
),
);
}
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],
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    ),
  );
}