runMyApp function

void runMyApp(
  1. Widget app, {
  2. dynamic enableLog = false,
  3. RoundAppRun? beforeRun,
  4. bool initWeChat = false,
  5. String? crashPrefixMsg,
  6. RoundAppRun? afterRun,
  7. bool clearGetxControllersBeforeExit = true,
})

Implementation

void runMyApp(
  Widget app, {
  /// 是否开启日志
  enableLog = false,

  /// 自定义启动前执行
  RoundAppRun? beforeRun,

  /// 初始化仿微信图片选择
  bool initWeChat = false,

  /// 是否开启日志
  String? crashPrefixMsg,

  /// 自定义启动后执行
  RoundAppRun? afterRun,

  /// 退出应用时,注销所有getx的controller
  bool clearGetxControllersBeforeExit = true,
}) {
  WidgetsFlutterBinding.ensureInitialized();

  LogUtils.initLog(enable: enableLog);

  if (clearGetxControllersBeforeExit) {
    MyGet.actionsBeforeExitApp.add(() {
      clearAllGetxControllers();
    });
  }

  baseBeforeRun().then((value) {
    /// 自定义启动前执行
    if (beforeRun != null) {
      beforeRun.call().then((value) {
        runBaseApp(
          app,
          initWeChat: initWeChat,
          crashPrefixMsg: crashPrefixMsg,
          afterRun: afterRun,
        );
      });
    } else {
      runBaseApp(
        app,
        initWeChat: initWeChat,
        crashPrefixMsg: crashPrefixMsg,
        afterRun: afterRun,
      );
    }
  });
}