Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修復「誤用 null courseMainInfo」的問題 #229

Merged
merged 5 commits into from
Feb 29, 2024

Conversation

ntut-xuan
Copy link
Collaborator

@ntut-xuan ntut-xuan commented Feb 28, 2024

Description

在這個 PR 上修復了誤用 global courseMainInfo 的問題,可能導致以下的 exception 不停觸發。

I/flutter (22396): ----------------FIREBASE CRASHLYTICS----------------
I/flutter (22396): NoSuchMethodError: The getter 'course' was called on null.
I/flutter (22396): Receiver: null
I/flutter (22396): Tried calling: course
I/flutter (22396): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
I/flutter (22396): #1      _CourseInfoPageState._loadCourseStudent (package:flutter_app/ui/pages/coursedetail/screen/course_info_page.dart:232:67)
I/flutter (22396): #2      _CourseInfoPageState.initState.<anonymous closure> (package:flutter_app/ui/pages/coursedetail/screen/course_info_page.dart:48:28)
I/flutter (22396): #3      new Future.microtask.<anonymous closure> (dart:async/future.dart:277:37)
I/flutter (22396): #4      _rootRun (dart:async/zone.dart:1390:47)
I/flutter (22396): #5      _CustomZone.run (dart:async/zone.dart:1300:19)
I/flutter (22396): #6      _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
I/flutter (22396): #7      _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1248:23)
I/flutter (22396): #8      _rootRun (dart:async/zone.dart:1398:13)
I/flutter (22396): #9      _CustomZone.run (dart:async/zone.dart:1300:19)
I/flutter (22396): #10     _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
I/flutter (22396): #11     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1248:23)
I/flutter (22396): #12     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
I/flutter (22396): #13     _startMicrotaskLoop (d
I/flutter (22396): ----------------------------------------------------

修復成使用 widget 的值,見 Files Changed。

How to review it?

  • 確保每一次點入課程後不會出現以上的 exception。

@ntut-xuan ntut-xuan added type: bug Something isn't working priority: medium labels Feb 28, 2024
@ntut-xuan ntut-xuan self-assigned this Feb 28, 2024
@ntut-xuan ntut-xuan marked this pull request as ready for review February 28, 2024 15:34
Copy link
Collaborator

@James-Lu-none James-Lu-none left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 Future<List<CourseStudent>> _getCourseStudent() async {
    TaskFlow taskFlow = TaskFlow();
    final task = IPlusGetStudentListTask(courseId: courseMainInfo.course.id);
    taskFlow.addTask(task);
    if (await taskFlow.start()) {
      List<CourseStudent> students = task.result;
      if (students != null) {
        return students;
      }
    }
    return <CourseStudent>[];
  }

should be

 Future<List<CourseStudent>> _getCourseStudent() async {
    TaskFlow taskFlow = TaskFlow();
    final courseMainInfo = widget.courseInfo.main; //here
    final task = IPlusGetStudentListTask(courseId: courseMainInfo.course.id);
    taskFlow.addTask(task);
    if (await taskFlow.start()) {
      List<CourseStudent> students = task.result;
      if (students != null) {
        return students;
      }
    }
    return <CourseStudent>[];
  }

Copy link
Collaborator

@James-Lu-none James-Lu-none left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ntut-xuan ntut-xuan merged commit 7cea4f1 into master Feb 29, 2024
4 checks passed
@ntut-xuan ntut-xuan deleted the hotfix/null_courseMainInfo branch February 29, 2024 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants