textField function

Widget textField(
  1. dynamic Item,
  2. Map<String, dynamic> map,
  3. dynamic pType, {
  4. dynamic row,
  5. dynamic minLines = 1,
  6. dynamic show = false,
})

Implementation

Widget textField(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(
           // name: Item["key"],
           // initialValue: map.containsKey(Item["key"]) ? map[Item["key"]].toString(): null,
           readOnly: show,
          controller: _texteditController,
            keyboardType: checkFieldType(Item["type"]),
            maxLines: 100,
            minLines: 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'),

             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 max Words is ${Item['validate']['pattern']}'),


            if(Item['validate'] != null && Item['validate']['minWords']!=null)
               FormBuilderValidators.minWordsCount(Item['validate']['minWords'] ,errorText: 'error min Words is ${Item['validate']['minWords']}'),


            if(Item['validate'] != null && Item['validate']['maxWords']!=null)
               FormBuilderValidators.minWordsCount(Item['validate']['maxWords'] ,errorText: 'error max Words is ${Item['validate']['maxWords']}'),

              // FormBuilderValidators.max(context, 70),
              //     (val){
              //   if(val < 0)
              //     return 'We cannot have a negative age';
              //   return null;
              // }
            ]),
          ),
        ],
      ),
    //)
    );

}