From 200a9668b54f3efa18574ee076fb2740db7c7278 Mon Sep 17 00:00:00 2001 From: Nils Reichardt Date: Tue, 19 Sep 2023 12:56:05 +0200 Subject: [PATCH] Fix `type 'Null' is not a subtype of type 'Course' in type cast` when popping the course create page (#1018) Fixes #1017 --- app/lib/groups/src/pages/course/create/course_create_page.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/lib/groups/src/pages/course/create/course_create_page.dart b/app/lib/groups/src/pages/course/create/course_create_page.dart index 9c3c6856c..19274ff2b 100644 --- a/app/lib/groups/src/pages/course/create/course_create_page.dart +++ b/app/lib/groups/src/pages/course/create/course_create_page.dart @@ -19,6 +19,7 @@ Future openCourseCreatePage( Course? course, String? schoolClassId, }) async { + // We use `dynamic` as type because we return either a `Course?` or `bool`. final createdCourse = await Navigator.push( context, IgnoreWillPopScopeWhenIosSwipeBackRoute( @@ -38,7 +39,7 @@ Future openCourseCreatePage( seconds: 2, ); } - return createdCourse as Course; + return createdCourse is Course ? createdCourse : null; } Future submit(BuildContext context) async {