Commit 9e085b2ad07174186308ab23ceb3bd2a584cb97c

Authored by 吴启风
1 parent 0cbdbb34

feat:异步返回优化

lib/pages/section/bloc/section_bloc.dart
... ... @@ -240,7 +240,7 @@ class SectionBloc extends Bloc<SectionEvent, SectionState> {
240 240 } else {
241 241 ///如果section锁了,请求当前unit下的section数据,查询解锁状态
242 242 int courseUnitId = courseSectionEntity.courseUnitId;
243   - await loading(() async {
  243 + CourseSectionEntity? result = await loading(() async {
244 244 List<CourseSectionEntity>? tempSectionEntities =
245 245 await LessonDao.courseSection(courseUnitId: courseUnitId);
246 246 if (tempSectionEntities != null) {
... ... @@ -258,6 +258,7 @@ class SectionBloc extends Bloc&lt;SectionEvent, SectionState&gt; {
258 258 return null;
259 259 }
260 260 });
  261 + return result;
261 262 }
262 263 } else {
263 264 ///section为空说明当前unit学完了,找下一个unit。(跨unit选section)
... ... @@ -272,7 +273,7 @@ class SectionBloc extends Bloc&lt;SectionEvent, SectionState&gt; {
272 273 if (nextCourseUnitDetail != null) {
273 274 if (nextCourseUnitDetail.lock == true) {
274 275 ///如果下一个unit是锁定状态,请求数据刷新查询解锁状态
275   - await loading(() async {
  276 + CourseSectionEntity? result = await loading(() async {
276 277 CourseUnitEntity? newCourseUnitEntity = await LessonDao.courseUnit(
277 278 _courseUnitEntity.nowCourseModuleId);
278 279  
... ... @@ -293,6 +294,7 @@ class SectionBloc extends Bloc&lt;SectionEvent, SectionState&gt; {
293 294 return null;
294 295 }
295 296 });
  297 + return result;
296 298 } else {
297 299 return checkCourseSectionLockedOfNextUnit(courseLessonId, nextCourseUnitDetail.id!, emitter);
298 300 }
... ... @@ -306,7 +308,6 @@ class SectionBloc extends Bloc&lt;SectionEvent, SectionState&gt; {
306 308 return null;
307 309 }
308 310 }
309   - return null;
310 311 }
311 312  
312 313 ///检查下一个unit的(第一个)section
... ...