Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振展开行并将子对象与水平SingleChildScrollView内部之间的空格对齐_Flutter_Dart - Fatal编程技术网

Flutter 颤振展开行并将子对象与水平SingleChildScrollView内部之间的空格对齐

Flutter 颤振展开行并将子对象与水平SingleChildScrollView内部之间的空格对齐,flutter,dart,Flutter,Dart,我正在创建一个包含子行列表的SliverList。这些行创建了如下图所示的布局。 我用SingleChildScrollView将右侧包含文本和删除图标的列包装起来,以应对小型设备上的溢出。 但是我现在想通过父行上的mainAxisAlignment:mainAxisAlignment.spaceBetween,将删除图标和发布的文本彼此分开放置。但是因为我使用了SingleChildScrollView,这就不可能了,因为水平空间现在是infinte 是否有方法仍然使用spaceBetween

我正在创建一个包含子行列表的SliverList。这些行创建了如下图所示的布局。
我用
SingleChildScrollView
将右侧包含文本和删除图标的列包装起来,以应对小型设备上的溢出。
但是我现在想通过父行上的
mainAxisAlignment:mainAxisAlignment.spaceBetween,
将删除图标和发布的文本彼此分开放置。但是因为我使用了SingleChildScrollView,这就不可能了,因为水平空间现在是infinte

是否有方法仍然使用
spaceBetween
Spacer()

SliverList(
  delegate: SliverChildListDelegate(
    [
      for (var i = 0; i < children.length; i++)
        Row(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            Padding(
              padding: const EdgeInsets.only(bottom: 10.0, left: 20.0),
              child: Text(
                children[i].issuanceDate),
              ),
            ),
            Column(
              //vertical line
            ),
            const SizedBox(
              width: 10,
            ),
            Expanded(
              child: Padding(
                padding: const EdgeInsets.symmetric(vertical: 10.0),
                child: Container(
                  padding: const EdgeInsets.symmetric(
                      vertical: 10.0, horizontal: 20.0),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(6),
                    color: Colors.white,
                    boxShadow: [
                      BoxShadow(
                        color: (Colors.grey[200])!,
                        offset: const Offset(0, 8),
                        blurRadius: 8,
                        spreadRadius: 1.0,
                      )
                    ],
                  ),
                  child: SingleChildScrollView(
                    scrollDirection: Axis.horizontal,
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Row(
                          children: [
                            Text(
                              children[i]
                                  .credentialSubject
                                  .documentName,
                              style:
                                  Theme.of(context).textTheme.bodyText1,
                            ),
                          ],
                        ),
                        Row(
                          mainAxisAlignment:
                              MainAxisAlignment.spaceBetween,
                          children: [
                            Text(
                              "${L.of(context).issued}${children[i].issuanceDate}",
                              overflow: TextOverflow.ellipsis,
                            ),
                            IconButton(
                              icon: Icon(
                                Icons.delete,
                                color: Theme.of(context).errorColor,
                              ),
                              onPressed: () => print("delete $i"),
                            ),
                          ],
                        )
                      ],
                    ),
                  ),
                ),
              ),
            ),
            const SizedBox(
              width: 20,
            ),
          ],
        )
    ],
  ),
),

无需使用singlechildscrollview(SCSW)来对抗溢出。对于用户来说,滚动互动程序似乎是一个糟糕的用户体验。您可以使用软包装之类的东西让流垂直流动。 如果仍要使用SCSW,则可以尝试通过将SCSW的子项包装在ConstrainedBox中来对SCSW施加约束

constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width),

谢谢你的建议。我现在使用了换行而不是行来对齐发布的文本和删除图标,但是换行仍然没有扩展到可用的垂直空间。我编辑了我的问题,以提供有关我的更改的更多细节。
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width),