taafee-mobile/lib/common/widgets/textfiled.dart
2023-10-17 17:22:55 +03:00

105 lines
3.1 KiB
Dart

import 'package:flutter/material.dart';
import '../const/const.dart';
class TextFieldWidget extends StatelessWidget {
final void Function(String) onChange;
final TextInputType keyboardType;
final String label;
final String? Function(String?)? validate;
final bool? obscure;
final String? initValue;
final TextInputAction? textInputAction;
final double? height;
final Widget? suffix;
final Widget? prefix;
final int? maxLines;
final String? suffixText;
const TextFieldWidget(
{super.key,
required this.onChange,
required this.keyboardType,
required this.label,
required this.validate,
this.initValue,
this.obscure,
this.textInputAction,
this.height,
this.suffix,
this.prefix,
this.maxLines,
this.suffixText});
@override
Widget build(BuildContext context) {
return Container(
transformAlignment: Alignment.topLeft,
// padding: const EdgeInsets.only(top: 1.5),
width: MediaQuery.of(context).size.width,
height: height ?? 55,
child: TextFormField(
textInputAction: textInputAction,
initialValue: initValue ?? '',
autovalidateMode: AutovalidateMode.onUserInteraction,
obscureText: obscure ?? false,
validator: validate,
cursorColor: AppColors.primeColor,
style: const TextStyle(decorationThickness: 0
// height: 1.6,
),
onChanged: onChange,
maxLines: maxLines ?? 1,
// minLines: 1,
keyboardType: keyboardType,
decoration: InputDecoration(
constraints: const BoxConstraints(maxHeight: 50),
suffixText: suffixText,
alignLabelWithHint: true,
prefixIcon: prefix,
prefixIconConstraints:
const BoxConstraints(maxWidth: 30, maxHeight: 30),
suffixIcon: suffix,
// suffixIconConstraints: const BoxConstraints(maxHeight: 20),
isDense: true,
errorStyle: const TextStyle(
height: 0.1,
fontSize: 10,
),
filled: true,
fillColor: Colors.white,
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: AppColors.borderColor,
),
borderRadius: BorderRadius.circular(5),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: AppColors.borderColor),
borderRadius: BorderRadius.circular(5),
),
labelText: label,
labelStyle: TextStyle(
color: AppColors.textColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: AppColors.borderColor,
),
borderRadius: BorderRadius.circular(5),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: AppColors.borderTextFiled,
),
borderRadius: BorderRadius.circular(5),
)),
),
);
}
}