mirrored_repositories/Intsagram-Clone/lib
import 'package:flutter/material.dart';

Widget formField({
  required TextEditingController controller,
  required TextInputType type,
  Function? onSubmit,
  Function? onChange,
  Function? onTap,
  required validate,
  required String? label,
  required IconData? prefix,
  IconData? suffix,
  Function? suffixPressed,
  bool isClickable = true,
  bool isPassword = false,


}) => TextFormField(
  controller: controller,
  keyboardType: type,
  obscureText: isPassword,
  enabled: isClickable,
  onFieldSubmitted: (value){
    onSubmit!(value);
  },
  onChanged: (String? s)
  {
    onChange!(s);
  },
  onTap: ()
  {
    onTap!();
    return;
  },
  validator :(String? s){
    return validate!(s);
  },
  decoration: InputDecoration(
    labelText: label,
    prefixIcon: Icon(
      prefix,
    ),
    suffixIcon: suffix != null ? IconButton(
      onPressed: suffixPressed!(),
      icon: Icon(
        suffix,
      ),
    ) : null,
    border: OutlineInputBorder(),
  ),
);
