CodePudding user response:
Try below code hope its helpful to you. set onTap function like below. refer InkWell class here
InkWell(
onTap: () {
//write your onTap void function here
print('Pressed');
},
child:Container(),//or your widget here
),
CodePudding user response:
The tip is the question mark. You have
void Function()?
onTap needs a not-nullable value:
void Function()
You need to wrap the function variable:
onTap : onTap!
or to prevent a crash you can just give an empty function to call when onTap is null:
onTap : onTap ?? (){}