Rain/lib/app/ui/widgets/text_form.dart

54 lines
1.3 KiB
Dart
Raw Normal View History

2023-06-17 20:57:57 +03:00
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class MyTextForm extends StatelessWidget {
const MyTextForm({
super.key,
required this.labelText,
required this.type,
required this.icon,
required this.controller,
2023-08-03 21:11:58 +03:00
required this.margin,
2023-06-17 20:57:57 +03:00
this.iconButton,
this.validator,
2023-08-03 21:11:58 +03:00
this.elevation,
this.focusNode,
2024-07-07 14:49:45 +03:00
this.onChanged,
2023-06-17 20:57:57 +03:00
});
final String labelText;
final TextInputType type;
final Icon icon;
final TextEditingController controller;
2023-08-03 21:11:58 +03:00
final EdgeInsets margin;
2023-06-17 20:57:57 +03:00
final Widget? iconButton;
final String? Function(String?)? validator;
2023-08-03 21:11:58 +03:00
final double? elevation;
final FocusNode? focusNode;
2024-07-07 14:49:45 +03:00
final Function(String)? onChanged;
2023-06-17 20:57:57 +03:00
@override
Widget build(BuildContext context) {
2023-08-03 21:11:58 +03:00
return Card(
elevation: elevation,
margin: margin,
2023-06-17 20:57:57 +03:00
child: TextFormField(
2023-08-03 21:11:58 +03:00
focusNode: focusNode,
2023-06-17 20:57:57 +03:00
controller: controller,
keyboardType: type,
2023-07-14 20:19:43 +03:00
style: context.textTheme.labelLarge,
2023-06-17 20:57:57 +03:00
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
horizontal: 12.5,
vertical: 0,
),
2023-06-17 20:57:57 +03:00
prefixIcon: icon,
suffixIcon: iconButton,
labelText: labelText,
),
validator: validator,
2024-07-07 14:49:45 +03:00
onChanged: onChanged,
2023-06-17 20:57:57 +03:00
),
);
}
}