Skip to content

Instantly share code, notes, and snippets.

@celikomer
Created May 5, 2020 17:52
Show Gist options
  • Select an option

  • Save celikomer/20b210fdf937b39ea3c7f366c59d0835 to your computer and use it in GitHub Desktop.

Select an option

Save celikomer/20b210fdf937b39ea3c7f366c59d0835 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class MyTextFormField extends StatelessWidget {
const MyTextFormField({
@required this.editingController,
this.validator,
this.hintText,
this.icon,
this.enabled = true,
this.keyboardType = TextInputType.text,
this.isPassword = false,
this.borderColor = Colors.black12,
this.autoValidate = false,
this.errorStyle = const TextStyle(color: Colors.black87),
this.maxLines = 1,
this.minLines,
this.hintStyle,
this.maxLength,
this.onChanged,
this.style,
this.inputFormatters,
Key key,
}) : super(key: key);
final TextEditingController editingController;
final String hintText;
final Icon icon;
final bool enabled;
final TextInputType keyboardType;
final bool isPassword;
final Function(String) validator;
final Color borderColor;
final bool autoValidate;
final TextStyle errorStyle;
final int maxLines;
final int minLines;
final TextStyle hintStyle;
final int maxLength;
final Function(String) onChanged;
final TextStyle style;
final List<TextInputFormatter> inputFormatters;
@override
Widget build(BuildContext context) {
return TextFormField(
autovalidate: autoValidate,
validator: validator,
controller: editingController,
obscureText: isPassword,
keyboardType: keyboardType,
maxLines: maxLines,
minLines: minLines,
maxLength: maxLength,
onChanged: onChanged,
style: style,
inputFormatters: inputFormatters,
decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.never,
labelStyle: TextStyle(color: Colors.black87),
hintText: hintText,
hintStyle: hintStyle,
prefixIcon: icon,
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: borderColor,
),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: borderColor,
),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red,
),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: borderColor,
),
),
errorStyle: errorStyle,
fillColor: Colors.white,
filled: true,
// labelText: hintText,
),
enabled: enabled,
);
}
}
@clkefe
Copy link
Copy Markdown

clkefe commented May 7, 2020

OMG
ty bro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment