簡體   English   中英

Flutter ${widget.name} 進入 TextFormField

[英]Flutter ${widget.name} into TextFormField

有什么方法可以將 ${widget.name} 放到 TextFormField 內的hintText 中嗎? 它適用於其他文本小部件,但在提示文本中我有一個錯誤

           Padding(
              padding: EdgeInsets.all(20.0),
              child: TextFormField(
                enabled: false,
                decoration: const InputDecoration(
                    border: UnderlineInputBorder(),
                    hintText: 'Name: ${widget.name}',
                    prefixIcon: Icon(Icons.done)),
              ),
            ),

這里的錯誤

屏幕截圖中的錯誤在最后一行顯示“無效的常量值”。 如果您從 InputDecoration 中刪除“const”,它應該可以工作。

Padding(
    padding: EdgeInsets.all(20.0),
    child: TextFormField(
    enabled: false,
    decoration: InputDecoration(
        border: UnderlineInputBorder(),
        hintText: 'Name: ${widget.name}',
        prefixIcon: Icon(Icons.done)),
    ),
),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM