I need to call a function when the application starts. I call it from the Main file, the function itself is in another file. I tried to do this, but there are no expected changes and the function in another file is highlighted with the warning
Null numberColumnFunction() The declaration 'numberColumnFunction' isn't referenced. Try removing the declaration of 'numberColumnFunction'.
What 's wrong with my call ?
My Main:
void main() async{
await ColumnView.numberColumnFunction();
runApp(const MyApp());
}
My fuction in class ColumnView:
@override
Widget build(BuildContext context) {
int numberColumn = 3;
int columnsPositioned = 5;
var visibilityColumn = false;
numberColumnFunction(){
if (numberColumn == 3) {
columnsPositioned = 8;
visibilityColumn = true;
}
else {
() {
null;
};
}
}
}
CodePudding user response:
Make a regular class like this and not use StatelessWidget or StatefulWidget class for calling only functions.
class ColumnView {
int numberColumn = 3;
int columnsPositioned = 5;
var visibilityColumn = false;
numberColumnFunction(){
if (numberColumn == 3) {
columnsPositioned = 8;
visibilityColumn = true;
}
else {
() {
null;
};
}
}
}
then call like that...
void main() async{
await ColumnView().numberColumnFunction();
runApp(const MyApp());
}