getSchoolInfoAsync method
Future<TCICGetSchoolInfoRepModel?>
getSchoolInfoAsync({
- TCICGetSchoolInfoRepModel? cacheSchoolInfo,
- bool needFireEvent = true,
Implementation
Future<TCICGetSchoolInfoRepModel?> getSchoolInfoAsync({TCICGetSchoolInfoRepModel? cacheSchoolInfo, bool needFireEvent = true}) async {
try {
var data = await networkService.getSchoolInfo();
if (data != null) {
if (data.errorCode == 0) {
sharedPreferences.setString("tcic-schoolInfo", json.encode(data.toJson()));
if (cacheSchoolInfo != null) {
if (cacheSchoolInfo.schoolId != data.schoolId) {
sharedPreferences.remove("tcic-schoolInfo");
_eventbus.fire(
MainProcessBreakenEvent(type: MainProcessBreakenEventEnum.schoolInfoChanged, data: TCICMainProcessBrokenEventData(errorCode: -1, errorMessage: _stringObs.getString(StringEnum.schoolInfoChanged), requestId: "")),
);
return null;
}
}
_schoolInfoObs.updateSchoolInfo(data);
if (needFireEvent) {
_eventbus.fire(MainEvent(type: EventTypeEnum.getSchoolInfoSuccess, data: data));
}
return data;
}
}
return null;
} catch (e) {
return null;
}
}