import 'package:flutter/material.dart'; class CustomTextField extends StatefulWidget { const CustomTextField({ super.key, required this.controller, required this.labelText, required this.inputType, this.errorText, this.isPassword = false, this.maxLines = 1, this.focusNode, }); final TextEditingController controller; final String labelText; final TextInputType inputType; final String? errorText; final bool isPassword; final int maxLines; final FocusNode? focusNode; @override State createState() => _CustomTextFieldState(); } class _CustomTextFieldState extends State { @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return TextField( controller: widget.controller, focusNode: widget.focusNode, keyboardType: widget.inputType, obscureText: widget.isPassword, enableSuggestions: !widget.isPassword, autocorrect: false, maxLines: widget.maxLines, textDirection: TextDirection.rtl, style: Theme.of(context).textTheme.bodyMedium, decoration: InputDecoration( contentPadding: const EdgeInsets.symmetric(vertical: 5, horizontal: 20), labelText: widget.labelText, alignLabelWithHint: true, labelStyle: Theme.of(context).textTheme.bodySmall?.copyWith(color: Theme.of(context).dividerColor), floatingLabelStyle: Theme.of(context).textTheme.bodySmall?.copyWith(color: Theme.of(context).dividerColor), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide(color: Theme.of(context).cardColor, width: 1.5) ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide(color: Theme.of(context).dividerColor, width: 1) ), filled: true, fillColor: Theme.of(context).cardColor, errorText: widget.errorText, errorStyle: Theme.of(context).textTheme.bodyMedium?.copyWith( color: Colors.red ), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: const BorderSide(color: Colors.red, width: 1.5) ), focusedErrorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: const BorderSide(color: Colors.red, width: 1.5) ), ), ); } }