Skip to content

Commit fa0966c

Browse files
committed
fix: guard AsyncValue access in header profile/avatar state
1 parent 68bd81b commit fa0966c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/screens/main/course_table/course_table_screen.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class CourseTableScreen extends ConsumerWidget {
107107
required AsyncValue<User?> profileAsync,
108108
required AsyncValue<File?> avatarAsync,
109109
}) {
110-
final profile = profileAsync.value;
110+
final profile = profileAsync.asData?.value;
111+
final avatarFile = avatarAsync.asData?.value;
111112
final isLoading = profileAsync is AsyncLoading<User?> && profile == null;
112113
final ownerName = switch (profileAsync) {
113114
AsyncLoading() => _placeholderOwnerName,
@@ -154,9 +155,9 @@ class CourseTableScreen extends ConsumerWidget {
154155
color: Theme.of(context).colorScheme.primary,
155156
),
156157
child: ClipOval(
157-
child: switch (avatarAsync.value) {
158-
final avatarFile? => Image.file(
159-
avatarFile,
158+
child: switch (avatarFile) {
159+
final file? => Image.file(
160+
file,
160161
fit: BoxFit.cover,
161162
),
162163
null => Center(

0 commit comments

Comments
 (0)