简体   繁体   中英

Calling login function in main.dart flutter

I have a login page named login.dart and in this flie I have signin() function I want to call this function in my main.dart

any idea??

Create simple dart class separate file define static or normal signin() function in that class.

after that Call that function whenever you need. It is simple and easy way to modularize your functionality and reusability.

You can pass variables as a parameters also.

main.dart

void main() {
  MyClass().signin();
  runApp(MyApp());
}

myClass.dart

class MyClass {
  ....
  void signin(){
  ....
  /* signin logic */
  }

}

In login.dart file you can also use this signin() function.

void main() {
  Login().signin();
  runApp(MyApp());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM