init method

Future<GlobalService> init({
  1. List<Locale>? supportedLocales,
  2. LocaleChangeCallback? localeChangeCallback,
})

Implementation

Future<GlobalService> init({
  List<Locale>? supportedLocales,
  LocaleChangeCallback? localeChangeCallback,
}) async {
  WidgetsBinding.instance.addObserver(this);
  eventBus = EventBus();
  sharedPreferences = await SharedPreferences.getInstance();
  this.localeChangeCallback = localeChangeCallback;
  //初始化本地语言配置
  _initLocale(supportedLocales);
  //初始化主题配置
  _initTheme();
  return this;
}