【问题标题】:I want to do the expandable list view as below in attached image. How can I achieve this type of functionality in flutter?我想做可扩展的列表视图,如下图所示。如何在颤振中实现这种类型的功能?
【发布时间】:2020-09-20 02:36:36
【问题描述】:

我怎样才能做到这一点?我曾尝试自定义 ExpansionTile,但无法在展开和折叠方面获得类似的效果。主要是前缀图标的大小较大,因此可扩展文本与日期不接近。此外,用于展开/折叠的后缀图标没有完全被背景颜色覆盖。

我还附上了一张我尝试过的图片。我使用https://pub.dev/packages/expandable#-readme-tab- 达到了类似的效果,但没有运气。

我真的被困在这个地方,需要任何帮助。 您的帮助将不胜感激。 谢谢。

【问题讨论】:

    标签: flutter dart flutter-layout expandablelistview expand


    【解决方案1】:

    刚刚实现,试试这个:

    ListView.builder(
            itemCount: 20,
            itemBuilder: (context, index) {
              return ExpandableNotifier(
                child: Card(
                  elevation: 4,
                  child: Expandable(
                    collapsed: Container(
                      width: MediaQuery.of(context).size.width,
                      height: 105,
                      child: ExpandableButton(
                        child: Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            Padding(
                              padding: EdgeInsets.all(10),
                              child: ClipOval(
                                child: Container(
                                  height: 80,
                                  width: 80,
                                  color: Colors.yellow,
                                ),
                              ),
                            ),
                            Expanded(
                              child: Padding(
                                padding: EdgeInsets.symmetric(vertical: 20),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Text(
                                      'Welkom bij Haaer',
                                      style: TextStyle(
                                        fontSize: 14.0,
                                        fontWeight: FontWeight.bold,
                                      ),
                                    ),
                                    Text(
                                      '2019/06/01 11:04',
                                      style: TextStyle(
                                        color: Colors.grey,
                                        fontSize: 12.0,
                                      ),
                                    ),
                                    Text(
                                      'blablablablablablablablablablablablablablablablablablablablablabla'
                                      'blablablablablablablablablablablablablablablablablablablablablabla'
                                      'blablablablablablablablablablablablablablablablablablablablablabla',
                                      softWrap: true,
                                      overflow: TextOverflow.ellipsis,
                                      maxLines: 2,
                                    ),
                                  ],
                                ),
                              ),
                            ),
                            Container(
                              color: Colors.yellow,
                              width: 30,
                              height: 105,
                              child: Icon(
                                Icons.keyboard_arrow_right,
                                color: Colors.white,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                    expanded: Container(
                      height: 200,
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Padding(
                            padding: EdgeInsets.all(10),
                            child: ClipOval(
                              child: Container(
                                height: 80,
                                width: 80,
                                color: Colors.purple,
                              ),
                            ),
                          ),
                          Expanded(
                            child: Padding(
                              padding: EdgeInsets.symmetric(vertical: 20),
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: <Widget>[
                                  Text(
                                    'Welkom bij Haaer',
                                    style: TextStyle(
                                      fontSize: 14.0,
                                      fontWeight: FontWeight.bold,
                                    ),
                                  ),
                                  Text(
                                    '2019/06/01 11:04',
                                    style: TextStyle(
                                      color: Colors.grey,
                                      fontSize: 12.0,
                                    ),
                                  ),
                                  Text(
                                    'blablablablablablablablablablablablablablablablablablablablablabla'
                                    'blablablablablablablablablablablablablablablablablablablablablabla'
                                    'blablablablablablablablablablablablablablablablablablablablablabla',
                                    softWrap: true,
                                  ),
                                  SizedBox(
                                    height: 5,
                                  ),
                                  Container(
                                    width: 80,
                                    height: 20,
                                    child: RaisedButton(
                                      padding: EdgeInsets.all(0),
                                      color: Colors.purple,
                                      child: Text('show'),
                                      onPressed: () {},
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                          ExpandableButton(
                            child: Container(
                              color: Colors.purple,
                              width: 30,
                              height: 200,
                              child: Icon(
                                Icons.keyboard_arrow_down,
                                color: Colors.white,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              );
            },
          ),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-20
      • 1970-01-01
      • 2021-02-17
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多