【问题标题】:Flutter - Positioned inside Stack inside Row doesn't render颤振 - 位于行内的堆栈内不渲染
【发布时间】:2021-08-03 08:03:21
【问题描述】:

我正在尝试将搜索图标定位在行中第一个输入的周边内,但出现错误和空白屏幕。

没有堆栈和定位的代码有效:

Row(
                      children: [
                        Expanded(
                          child: Padding(
                            padding: const EdgeInsets.only(right: 8.0),
                            child: InputText(
                              label: 'Article infrigit',
                              readOnly: true,
                              placeholder: '29.1',
                            ),
                          ),
                        ),
                        Image.asset('assets/images/searchIcon.png',
                            width: 32.0),
                        Expanded(
                          child: InputText(
                            label: 'Import Sanció €',
                            readOnly: true,
                            placeholder: '100,00',
                          ),
                        ),
                      ],
                    ),

Stack 和 Positioned 的代码没有:

Row(
                      children: [
                        Stack(children: [
                          Expanded(
                            child: Padding(
                              padding: const EdgeInsets.only(right: 8.0),
                              child: InputText(
                                label: 'Article infrigit',
                                readOnly: true,
                                placeholder: '29.1',
                              ),
                            ),
                          ),
                          Positioned(
                            top: 0,
                            right: 0,
                            child: Image.asset('assets/images/searchIcon.png',
                                width: 32.0),
                          ),
                        ]),
                        Expanded(
                          child: InputText(
                            label: 'Import Sanció €',
                            readOnly: true,
                            placeholder: '100,00',
                          ),
                        ),
                      ],
                    ),

before the stack

其中一个布局例外说: layout exception

【问题讨论】:

    标签: flutter stack flutter-positioned


    【解决方案1】:

    解决方案是将 Stack 包装到 SizedBox 中以赋予其高度并展开以赋予其全宽

    在这里找到答案Flutter: RenderBox was not laid out

    【讨论】:

      猜你喜欢
      • 2021-05-25
      • 2021-05-14
      • 2018-11-21
      • 2020-07-17
      • 2022-10-17
      • 1970-01-01
      • 2021-04-28
      • 1970-01-01
      • 2021-06-26
      相关资源
      最近更新 更多