DiscoverModule/lib/ui_screen/interactionform/widget/interatciontextfield.dart

71 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// ignore: must_be_immutable
class InteractionTextField extends StatelessWidget {
String labelText;
TextEditingController controller;
String? hintText;
IconButton? suffixIcon;
bool? enabled = true;
bool? obscure = false;
Function onChanged;
TextInputType? inputType;
int? maxchars = 0;
int? maxlines = 1;
int? minlines = 0;
InteractionTextField(
{super.key,
required this.controller,
this.hintText,
required this.labelText,
this.suffixIcon,
this.enabled,
this.maxchars,
this.maxlines,
this.inputType,
this.minlines,
required this.onChanged,
this.obscure});
@override
Widget build(BuildContext context) {
return TextField(
controller: controller,
style: const TextStyle(fontSize: 16),
enabled: enabled,
obscureText: obscure ?? false,
onTap: () {},
maxLines: maxlines ?? 1,
minLines: minlines,
keyboardType: inputType ?? TextInputType.name,
onChanged: (value) {
onChanged(value);
},
onSubmitted: (value) {
onChanged(value);
},
inputFormatters: [
inputType == TextInputType.number
? FilteringTextInputFormatter.digitsOnly
: maxchars == 0
? LengthLimitingTextInputFormatter(100)
: LengthLimitingTextInputFormatter(maxchars),
],
decoration: InputDecoration(
isDense: true,
// contentPadding: const EdgeInsets.symmetric(
// horizontal: 10,
// vertical: 18,
// ),
contentPadding: EdgeInsets.all(13.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
suffixIcon: suffixIcon,
hintText: hintText,
),
);
}
}