[英]Flutter textformfield
如何在文本字段小部件中擁有新行屬性? 因此,當到達某個點時輸入的文本,它會轉移到一個新行。 誰能幫我解決這個問題?
代碼 :
body: Center(
child: Container(
height: 500,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 2,
),
borderRadius: BorderRadius.circular(10)),
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: TextFormField(
decoration: InputDecoration(
hintText: 'UserName',
hintStyle:
TextStyle(fontWeight: FontWeight.w400, fontSize: 24.0)),
),
),
),
)
輸出:
從官方文檔中可以將 maxLines 屬性設置為 null 以取消對行數的限制。 默認情況下,它是 1,這意味着這是一個單行文本字段。 maxLines 不能為零。
你只需要添加maxLines: null
body: Center(
child: Container(
height: 500,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 2,
),
borderRadius: BorderRadius.circular(10)),
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: TextFormField(
maxLines: null,
decoration: InputDecoration(
hintText: 'UserName',
hintStyle:
TextStyle(fontWeight: FontWeight.w400, fontSize: 24.0)),
),
),
),
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.