74 lines
2.0 KiB
Dart
74 lines
2.0 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import 'spaces.dart';
|
||
|
|
|
||
|
|
class CustomTextField extends StatelessWidget {
|
||
|
|
final TextEditingController controller;
|
||
|
|
final String label;
|
||
|
|
final Function(String value)? onChanged;
|
||
|
|
final bool obscureText;
|
||
|
|
final TextInputType? keyboardType;
|
||
|
|
final TextInputAction? textInputAction;
|
||
|
|
final TextCapitalization? textCapitalization;
|
||
|
|
final bool showLabel;
|
||
|
|
final Widget? prefixIcon;
|
||
|
|
final Widget? suffixIcon;
|
||
|
|
final bool readOnly;
|
||
|
|
|
||
|
|
const CustomTextField({
|
||
|
|
super.key,
|
||
|
|
required this.controller,
|
||
|
|
required this.label,
|
||
|
|
this.onChanged,
|
||
|
|
this.obscureText = false,
|
||
|
|
this.keyboardType,
|
||
|
|
this.textInputAction,
|
||
|
|
this.textCapitalization,
|
||
|
|
this.showLabel = true,
|
||
|
|
this.prefixIcon,
|
||
|
|
this.suffixIcon,
|
||
|
|
this.readOnly = false,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Column(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
|
children: [
|
||
|
|
if (showLabel) ...[
|
||
|
|
Text(
|
||
|
|
label,
|
||
|
|
style: const TextStyle(
|
||
|
|
fontSize: 14,
|
||
|
|
fontWeight: FontWeight.w700,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
const SpaceHeight(12.0),
|
||
|
|
],
|
||
|
|
TextFormField(
|
||
|
|
controller: controller,
|
||
|
|
onChanged: onChanged,
|
||
|
|
obscureText: obscureText,
|
||
|
|
keyboardType: keyboardType,
|
||
|
|
textInputAction: textInputAction,
|
||
|
|
textCapitalization: textCapitalization ?? TextCapitalization.none,
|
||
|
|
readOnly: readOnly,
|
||
|
|
decoration: InputDecoration(
|
||
|
|
prefixIcon: prefixIcon,
|
||
|
|
suffixIcon: suffixIcon,
|
||
|
|
border: OutlineInputBorder(
|
||
|
|
borderRadius: BorderRadius.circular(16.0),
|
||
|
|
borderSide: const BorderSide(color: Colors.grey),
|
||
|
|
),
|
||
|
|
enabledBorder: OutlineInputBorder(
|
||
|
|
borderRadius: BorderRadius.circular(16.0),
|
||
|
|
borderSide: const BorderSide(color: Colors.grey),
|
||
|
|
),
|
||
|
|
hintText: label,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|