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");
fireMainBreakEvent(
MainProcessBreakenEventEnum.schoolInfoChanged,
-1,
);
return null;
}
}
_schoolInfoObs.updateSchoolInfo(data);
if (needFireEvent) {
_eventbus.fire(
MainEvent(type: EventTypeEnum.getSchoolInfoSuccess, data: data),
);
}
return data;
}
}
return null;
} catch (e) {
return null;
}
}