мой случай: мне нужно удалить значок по умолчанию в текстовом поле, когда obscureText = true, потому что я использую suffixIcon для ввода декора.
введите здесь описание изображения
мой код такой:
Код: Выделить всё
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
child: TextField(
obscureText: _obscured,
controller: _password,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
icon: Icon(Icons.lock,
size: 32,
color: Colors.black),
labelText: "Password",
// hintText: "Password",
labelStyle: TextStyle(
color: Colors.black),
suffixIcon: IconButton(
icon: Icon(_obscured ? Icons.visibility_off : Icons.visibility),
onPressed: () {
setState(() {
_obscured = !_obscured;
},
);
},
),
// alignLabelWithHint: false,
// filled: true,
),
),
),
Подробнее здесь: https://stackoverflow.com/questions/791 ... on-flutter