textFieldPassword function
Widget
textFieldPassword(
- dynamic Item,
- Map<String, dynamic> map,
- dynamic pType, {
- dynamic row,
- dynamic minLines = 1,
- dynamic show = false,
})
Implementation
Widget textFieldPassword(Item, Map<String, dynamic> map, pType, {row,minLines=1,show=false}) {
StreamController<bool> _controller= StreamController.broadcast();
TextEditingController _texteditController=new TextEditingController(text: map[Item["key"]]);
printO("Contains ${Item["key"]} ${map.containsKey(Item["key"])}");
return
StreamBuilder<bool>(
stream: _controller.stream,
initialData: true,
builder: (context, snapshot) {
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,
//keyboardType: TextInputType.
readOnly: show,
controller: _texteditController,
//maxLines: 100,
// minLines: 1,
style: ThemeApp!.headline2,
obscureText: snapshot.data??true,
onSaved: (value) {
if(value!=null)
map[Item["key"]] = value;
},
decoration: InputDecoration(
suffixIcon: InkWell(
child: Icon(snapshot.data!?Icons.visibility : Icons.visibility_off),
onTap: (){
_controller.add(!snapshot.data!);
},
),
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 match Words is ${Item['validate']['pattern']}'),
// FormBuilderValidators.max(context, 70),
// (val){
// if(val < 0)
// return 'We cannot have a negative age';
// return null;
// }
]),
),
],
),
//)
);
}
);
}