【问题标题】:Flutter DropdownButtonFormField List of items symmetricalFlutter DropdownButtonFormField 项目列表对称
【发布时间】:2021-07-22 15:51:51
【问题描述】:

我想在屏幕中间显示DropdownButtonFormField 的项目列表。它永远不会与中心对齐。 DropdownButtonFormField 已经居中。左右间距不同。

【问题讨论】:

    标签: flutter layout dropdown


    【解决方案1】:

    你应该试试这个 在 Padding() 小部件

    中添加 DropdownButtonFormField()
    Padding (
      padding:EdgeInsets.all(16.0),
      child:DropdownButtonFormField(),
    ),
    

    【讨论】:

    • 这无济于事。它仍然不是对称对齐的。
    • 你能发布你的新图片吗
    【解决方案2】:

    使用这个

    DropdownButton(
         isExpanded: true
         value: fieldSelected,
         items: items.map<DropdownMenuItem<String>>((var value) {
            return DropdownMenuItem<String>(
              value: value,
              child: Center(
                     child: Text(
                            "Your text",
                            textAlign: TextAlign.center,
                          ),
                        ),
                     );
               }).toList(),
          ),
    

    【讨论】:

    • 我想将整个列表居中,而不是列表项上的文本。
    猜你喜欢
    • 2022-08-17
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 2020-02-06
    • 1970-01-01
    • 1970-01-01
    • 2021-12-02
    • 1970-01-01
    相关资源
    最近更新 更多