reusableTextField function

TextField reusableTextField(
  1. String text,
  2. IconData icon,
  3. bool isPasswordType,
  4. TextEditingController controler,
  5. String? errorText,
  6. dynamic onChanged(
    1. String
    ),
  7. bool submitted,
)

Implementation

TextField reusableTextField(String text, IconData icon, bool isPasswordType, TextEditingController controler, String? errorText, Function(String)  onChanged, bool submitted) {
  return TextField(
    controller: controler,
    obscureText: isPasswordType,
    enableSuggestions: !isPasswordType,
    autocorrect: !isPasswordType,
    cursorColor: Colors.black54,
    onChanged: onChanged,
    decoration: InputDecoration(
        prefixIcon: Icon(icon,
            color: Colors.black54
        ),
        errorText: submitted ?errorText:null,
        labelText: text,
        labelStyle: TextStyle(color: Colors.black.withOpacity(0.9)),
        filled: true,
        floatingLabelBehavior: FloatingLabelBehavior.never,
        fillColor: Colors.white.withOpacity(0.3),
        border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(20.0),
            borderSide: const BorderSide(width: 0, style: BorderStyle.none)
        )
    ),
    keyboardType: isPasswordType ? TextInputType.visiblePassword : TextInputType
        .emailAddress,
  );
}