samedi 3 juillet 2021

i want to use if condition in a flutter widget function to save the data in the text field like mail or password in flutter

Widget buildtextfield( IconData icon, String hintText, bool password, bool email) { switch() return Padding(

  padding: const EdgeInsets.only(bottom: 8.0),
  child: TextField(
              if(password){
             //  error expected an identifier
                   onChanged: (value) => setState(() => this.password = value),
                   onSubmitted: (value) => setState(() => this.password = value),
              }

      textInputAction: TextInputAction.done,
      obscureText: password,
      keyboardType: email ? TextInputType.emailAddress : TextInputType.text,

      decoration: InputDecoration(
          prefixIcon: Icon(icon),
          enabledBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.grey),
            borderRadius: BorderRadius.all(Radius.circular(35.0)),
          ),
          focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.grey),
            borderRadius: BorderRadius.all(Radius.circular(35.0)),
          ),
          contentPadding: EdgeInsets.all(10),
          hintText: hintText,
          hintStyle: TextStyle(fontSize: 14, color: Colors.grey))),
);

}

Aucun commentaire:

Enregistrer un commentaire