InkWell tile({String? date}) {
return InkWell(
child: SizedBox(
height: 40,
child: ListTile(
title: Text(
date?? 'Null',
style: const TextStyle(fontSize: 16),
),
),
),
onTap: (() {
if(date != null){ setState(() {
dateController.text = date; });}}),);
I have a tappable List Tile with the title variable 'date' which I will assign later, so I am going to pass this to another file as shown now:
randomParameter: anotherFile(
...
tile(), // might be an error idk
inside file where tile widget will be imported to:
anotherFile(required InkWell tile){
const String today = 'Today';
const String tmrw = 'Tomorrow';
const String week = 'Next Week';
ExpansionTile(children: [tile(today), tile(tmrw), tile(week)]) ////Error!
Error: The expression doesn't evaluate to a function, so it can't be invoked. The method 'call' isn't defined for the class 'InkWell'.
CodePudding user response:
The error says that another file doesnt evaluate to a function
For example a function will look like
void someFunction()
{
}
In this case you are adding an expansion tile to a parameter which i assume you are trying to return an ExpansionTile
If you wish to return a widget then you can try writing it like
Widget anotherFile(required InkWell tile){
return ExpansionTile();
}
Now this method will return a wodget of type expansion tile
CodePudding user response:
change anotherFile(required InkWell tile){
to anotherFile(required InkWell Function(string) tile){