textFieldPhone function
Widget
textFieldPhone(
- dynamic Item,
- Map<String, dynamic> map,
- dynamic pType, {
- dynamic row,
- dynamic minLines = 1,
- dynamic show = false,
})
Implementation
Widget textFieldPhone(Item, Map<String, dynamic> map, pType, {row,minLines=1,show=false}) {
printO("Contains ${Item["key"]} ${map.containsKey(Item["key"])}");
TextEditingController _texteditController=new TextEditingController(text: map[Item["key"]]);
return
Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
flex: 1,
fit: FlexFit.loose,
child: Text(Item["label"])),
const SizedBox(height: 5),
TextFormField(
readOnly: show,
// name: Item["key"],
//initialValue: map.containsKey(Item["key"]) ? map[Item["key"]].toString(): null,
controller: _texteditController,
keyboardType: TextInputType.phone,
maxLines: 100,
minLines: 1,
style: ThemeApp!.headline2,
onSaved: (value) {
if(value!=null)
map[Item["key"]] = value;
},
decoration: InputDecoration(
hintText: Item['hideLabel'] != null && Item['hideLabel']
? ''
: Item["label"],
hintStyle: ThemeApp!.hintStyle,
border: OutlineInputBorder(
borderSide: BorderSide(color: ThemeApp!.borderColor, width: 1),
borderRadius: BorderRadius.all(Radius.circular(10)))
// ,fillColor: Color(0xfff0f0f5),
),
validator: FormBuilderValidators.compose([
if (Item['validate'] != null &&
Item['validate']['required'] != null &&
Item['validate']['required'])
FormBuilderValidators.required(errorText: Item['validate']['customMessage']??'Field is Required'),
FormBuilderValidators.phoneNumber(errorText: 'Phone Number '),
if(Item['validate'] != null && Item['validate']['minLength']!=null)
FormBuilderValidators.minLength(Item['validate']['minLength'] ,errorText: 'error min Length is ${Item['validate']['minLength']}'),
if(Item['validate'] != null && Item['validate']['maxLength']!=null)
FormBuilderValidators.minLength(Item['validate']['maxLength'] ,errorText: 'error max Length is ${Item['validate']['maxLength']}'),
if(Item['validate'] != null && Item['validate']['pattern']!=null)
FormBuilderValidators.match(RegExp(Item['validate']['pattern']) ,errorText: 'error match pattern is ${Item['validate']['pattern']}'),
// FormBuilderValidators.numeric(context, errorText: 'La edad debe ser numérica.'),
// FormBuilderValidators.max(context, 70),
// (val){
// if(val < 0)
// return 'We cannot have a negative age';
// return null;
// }
]),
),
],
),
//)
);
}