How to call a function when launching an application

Verc

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;
      };
      }
    }
}
Hemali Vekariya

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());
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How on ios when launching an application, request permission?

Call function when application loads

How to call a function when a user swipes off the application in android?

How to avoid application crashing when launching AlertDialog using AsyncTask() in ANDROID?

How do I assign WM_CLASS when launching an application

Application crash when I call a function

openURL function is not call when application in inactive/Terminated

Internal NPE when launching JavaFX Application

Automatically changing Eclipse perspective when launching an application

Swing Application not launching when trying to test with robotframework

Android : savedInstanceState null when launching application

Access denied when launching WPF application

how to call specific function from outside an application

How to solve "Could not find artifact javax.xml.ws:WebServiceContext" error when launching application with maven?

How do I prevent the Photos application from launching when my iPhone gets plugged in?

When launching Chrome headless as a command line application process from Java, how do I correctly pass arguments in?

How can I pass data loaded when my application finished launching thru my UITabBar to a UITableView?

How to call SignalR hub when application start?

How do I diagnose "There was an error launching the application"?

how to call a function in when button click

How to call a function when using ajax promise

How to call a function when input is cleared in AngularJS?

How to call function when variable is available in angularjs

How to call function when a certain date arrives

How to call a function when store has data

How to Call a Function when Ok is pressed in an UIAlert

How to call a function when "user action" ends?

How to call function when collection view is reloaded?

How to call a function when its name is a string

TOP Ranking

HotTag

Archive