Flutter: Cupertino TextField with hintText

I'd like to add hint text to CupertinoTextField without importing the material theme. Up to this point I tried mixing CupertinoTextField with InputDecoration like so:

CupertinoTextField(
   decoration: InputDecoration.collapsed(
       hintText: 'Enter you email'
   )
)

which results in the following error:

The argument type 'InputDecoration' can't be assigned to the parameter type 'BoxDecoration'

enter image description here

Upvotes: 11

Views: 12299

Answers (2)

Mohamed hassan kadri
Mohamed hassan kadri

Reputation: 1069

In the CupertinoTextField it's called placeholder not hint

you cant add like that

CupertinoTextField(
   placeholder: "Your placeholder here",
)

and for styling the placeholder i think you can't at the moment because its static and it's not customizable on iOS either.

Upvotes: 4

bytesizedwizard
bytesizedwizard

Reputation: 6033

I think you can achieve what you want with the placeholder property of CupertinoTextField.

Example:

CupertinoTextField(
   placeholder: "Enter Email",
)

Upvotes: 21

Related Questions