78 lines
2.7 KiB
Dart
78 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:gascom/constants/app_theme.dart';
|
|
|
|
class AppTextField extends StatelessWidget {
|
|
const AppTextField(
|
|
{super.key,
|
|
required this.controller,
|
|
required this.keyboardType,
|
|
this.onChanged,
|
|
this.errorText,
|
|
this.fillColor,
|
|
this.textColor,
|
|
this.isFilled,
|
|
this.isCentered,
|
|
this.maxCharacters,
|
|
this.inputFormatters,});
|
|
|
|
final TextEditingController controller;
|
|
final TextInputType keyboardType;
|
|
final void Function(String)? onChanged;
|
|
final String? errorText;
|
|
final Color? fillColor;
|
|
final Color? textColor;
|
|
final bool? isFilled;
|
|
final bool? isCentered;
|
|
final int? maxCharacters;
|
|
final List<TextInputFormatter>? inputFormatters;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
height: 40,
|
|
child: TextField(
|
|
controller: controller,
|
|
keyboardType: keyboardType,
|
|
onChanged: onChanged,
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
fontWeight: FontWeight.w500,
|
|
color: textColor ?? const Color.fromARGB(255, 20, 20, 20),
|
|
),
|
|
textAlign: isCentered ?? false ? TextAlign.center : TextAlign.start,
|
|
autocorrect: false,
|
|
inputFormatters: inputFormatters,
|
|
cursorColor: textColor ?? const Color.fromARGB(255, 20, 20, 20),
|
|
cursorRadius: const Radius.circular(10),
|
|
maxLength: maxCharacters,
|
|
decoration: InputDecoration(
|
|
counterText: "",
|
|
fillColor: fillColor ?? const Color.fromARGB(255, 20, 20, 20),
|
|
filled: isFilled ?? false,
|
|
contentPadding:
|
|
const EdgeInsets.symmetric(vertical: 5, horizontal: 20),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(30),
|
|
borderSide:
|
|
const BorderSide(color: AppTheme.textColor, width: 1)),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(30),
|
|
borderSide:
|
|
const BorderSide(color: AppTheme.textColor, width: 1)),
|
|
errorText: errorText,
|
|
errorStyle: Theme.of(context)
|
|
.textTheme
|
|
.bodyMedium
|
|
?.copyWith(color: AppTheme.redColor),
|
|
errorBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
borderSide: const BorderSide(color: AppTheme.redColor, width: 1)),
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
borderSide: const BorderSide(color: AppTheme.redColor, width: 1)),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|