Flutter-如何使用自定义前缀设计制作自定义输入字段?

问题描述 投票:0回答:1

如何制作带有自定义前缀设计的自定义输入字段?就像下面的图片一样

custom Input

我为此做了很多尝试,但是无法在输入中添加前缀部分

flutter flutter-layout
1个回答
0
投票

您可以使用prefixIconInputDecorator属性显示某个图形。

TextField(
  decoration: InputDecoration(
    prefixIcon: SizedBox(
      width: 50,
      child: Center(
        child: Text(
          '+91',
          style: TextStyle(color: Colors.black),
        ),
      ),
    ),
  ),
),

您也可以使用prefix属性,但是如果文本字段未聚焦,则文本将消失。

© www.soinside.com 2019 - 2024. All rights reserved.