hintText: "Mot de passe",
prefixIcon: Icon(
Icons.lock,
color: Color(0xfff28800),
),
//hide/show
suffixIcon: InkWell(
onTap: _togglePasswordVew,
child: Icon(Icons.visibility_off, color: Colors.grey,),
)
// I want to test the Icons.visibility_off with a showdialoge message
CodePudding user response:
You can use GetX package, and make a function returns the dialog.
Like this:
openDialog(){
Get.defaultDialog(
title: 'Some message',
actions: [
Row(
children: [
MaterialButton(onPressed: (){}, child: Text('Ok'),),
MaterialButton(onPressed: (){}, child: Text('Cancel'),),
]
),
],
);
}
And in your ui code you can do like this:
Getbuilder<ControllerClass>(
buileder: (controller) => hintText: "Mot de passe",
prefixIcon: Icon(
Icons.lock,
color: Color(0xfff28800),
),
//hide/show
suffixIcon: InkWell(
onTap: controller.openDialog(),
child: Icon(Icons.visibility_off, color: Colors.grey,),),
),
CodePudding user response:
you can use like
suffixIcon: InkWell(
onTap: () async {
_togglePasswordVew();
await showDialog(
context: context,
builder: (context) {
return AlertDialog(...);
},
);
},