Good or Bad: Declaring main method async in Dart / Flutter

后端 未结 2 609
盖世英雄少女心
盖世英雄少女心 2021-02-05 04:55

I declare one global variable in the entire app - SharedPreferences prefs, and initialize it in main method.

However, SharedPreferences

2条回答
  •  醉话见心
    2021-02-05 05:16

    Good one from @jamesdlin .

    A literal answer for your question

    How does main method gets invoked and how it works in general in Dart / Flutter?

    For Android apps, Dart entry point is invoked via DartExecutor. You can take a look at here: DartExecutor class

    There is a brief document, how you can manually do what FlutterApplication does for you: wiki/Experimental:-Launch-Flutter-with-non-main-entrypoint

    Classes you want to look for, if you want to dig deeper: FlutterApplication, FlutterActivity, FlutterMain .

提交回复
热议问题