Files
Tanami_App/lib/shared/components/text_from_field_widget.dart

140 lines
4.1 KiB
Dart
Raw Normal View History

2024-05-28 16:35:33 +05:30
import 'package:control_style/control_style.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:tanami_app/core/styles/app_color.dart';
Widget textFormField({
final dynamic validator,
final TextEditingController? textEditingController,
final String? hintText,
final Widget? leadingIcon,
final Color? prefixIconColor,
final String? validatorText,
final String? value,
final bool? readonly,
final bool? enabled,
final int? maxlines,
final TextInputType? texttype,
final dynamic inputFormatters,
final Function(String)? onInput,
final VoidCallback? onTap,
final TextCapitalization? textCapV,
final Widget? suffixIcon,
2024-06-11 16:53:29 +05:30
final TextAlign? txtAlign,
2024-05-28 16:35:33 +05:30
}) {
return TextFormField(
2024-06-11 16:53:29 +05:30
textAlign: txtAlign ?? TextAlign.start,
2024-05-28 16:35:33 +05:30
validator: validator,
textAlignVertical: TextAlignVertical.center,
2024-06-06 18:40:58 +05:30
cursorColor: AppColor.primaryColor2,
2024-05-28 16:35:33 +05:30
initialValue: value,
readOnly: readonly!,
onTap: onTap,
enabled: enabled,
maxLines: maxlines,
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: textEditingController,
textCapitalization: textCapV ?? TextCapitalization.none,
decoration: InputDecoration(
fillColor: AppColor.plainWhite,
filled: true,
hintStyle: GoogleFonts.dmSans(
color: AppColor.hintTextColor,
fontSize: 15,
fontWeight: FontWeight.w400,
),
hintText: hintText,
prefixIconColor: prefixIconColor,
prefixIcon: leadingIcon,
errorStyle: GoogleFonts.dmSans(
color: AppColor.txtErrorColor,
fontSize: 14,
fontWeight: FontWeight.w400,
),
suffixIcon: suffixIcon,
border: DecoratedInputBorder(
child: OutlineInputBorder(
borderRadius: BorderRadius.circular(12.0),
borderSide: const BorderSide(color: AppColor.txtBorderColor),
),
shadow: const [
BoxShadow(
color: AppColor.txtBorderShadowColor,
blurRadius: 2,
offset: Offset(0, 1),
spreadRadius: 0.50,
)
],
),
contentPadding:
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
errorBorder: DecoratedInputBorder(
child: OutlineInputBorder(
borderRadius: BorderRadius.circular(12.0),
borderSide: const BorderSide(color: AppColor.txtErrorBorderColor),
),
shadow: const [
BoxShadow(
color: AppColor.txtBorderShadowColor,
blurRadius: 2,
offset: Offset(0, 1),
spreadRadius: 0.50,
)
],
),
disabledBorder: DecoratedInputBorder(
child: OutlineInputBorder(
borderRadius: BorderRadius.circular(12.0),
borderSide: const BorderSide(color: AppColor.txtBorderColor),
),
shadow: const [
BoxShadow(
color: AppColor.txtBorderShadowColor,
blurRadius: 2,
offset: Offset(0, 1),
spreadRadius: 0.50,
)
],
),
enabledBorder: DecoratedInputBorder(
child: OutlineInputBorder(
borderRadius: BorderRadius.circular(12.0),
borderSide: const BorderSide(color: AppColor.txtBorderColor),
),
shadow: const [
BoxShadow(
color: AppColor.txtBorderShadowColor,
blurRadius: 2,
offset: Offset(0, 1),
spreadRadius: 0.50,
)
],
),
focusedBorder: DecoratedInputBorder(
child: OutlineInputBorder(
borderRadius: BorderRadius.circular(12.0),
borderSide: const BorderSide(color: AppColor.txtBorderColor),
),
shadow: const [
BoxShadow(
color: AppColor.txtBorderShadowColor,
blurRadius: 2,
offset: Offset(0, 1),
spreadRadius: 0.50,
)
],
),
),
style: GoogleFonts.dmSans(
color: AppColor.charcoalColor,
fontSize: 14,
fontWeight: FontWeight.w500,
),
keyboardType: texttype,
inputFormatters: inputFormatters,
onChanged: (value) {
onInput?.call(value);
},
);
}