Update: 2026-08-08 13:33:53
This commit is contained in:
@@ -350,29 +350,32 @@ class UserHeader extends StatelessWidget {
|
||||
),
|
||||
child: controller.isloading
|
||||
? const CircularProgressIndicator(color: Colors.white)
|
||||
: CircleAvatar(
|
||||
backgroundImage: (box
|
||||
.read(BoxName.driverPhotoUrl)
|
||||
?.toString()
|
||||
.isNotEmpty ==
|
||||
true)
|
||||
? NetworkImage(box.read(BoxName.driverPhotoUrl))
|
||||
: null,
|
||||
: Builder(builder: (context) {
|
||||
final photoUrl =
|
||||
box.read(BoxName.driverPhotoUrl)?.toString() ?? '';
|
||||
final avatarImage = photoUrl.isNotEmpty
|
||||
? NetworkImage(photoUrl)
|
||||
: null;
|
||||
|
||||
// [تعديل هام]: في حال فشل تحميل الصورة (غير موجودة)
|
||||
onBackgroundImageError: (exception, stackTrace) {
|
||||
// طباعة الخطأ في الكونسول للتوضيح
|
||||
debugPrint(
|
||||
"Profile image not found or error loading: $exception");
|
||||
// استدعاء نافذة التنبيه
|
||||
_showUploadPhotoDialog(context, controller);
|
||||
},
|
||||
return CircleAvatar(
|
||||
backgroundImage: avatarImage,
|
||||
|
||||
// أيقونة بديلة تظهر في الخلفية إذا لم تكن الصورة موجودة
|
||||
backgroundColor: Colors.grey.shade300,
|
||||
child: const Icon(Icons.person,
|
||||
size: 40, color: Colors.white),
|
||||
),
|
||||
// Flutter يمنع onBackgroundImageError بلا صورة
|
||||
// (assertion)، فنمرّره فقط عند وجود صورة فعلية.
|
||||
onBackgroundImageError: avatarImage == null
|
||||
? null
|
||||
: (exception, stackTrace) {
|
||||
debugPrint(
|
||||
"Profile image not found or error loading: $exception");
|
||||
_showUploadPhotoDialog(context, controller);
|
||||
},
|
||||
|
||||
// أيقونة بديلة تظهر في الخلفية إذا لم تكن الصورة موجودة
|
||||
backgroundColor: Colors.grey.shade300,
|
||||
child: const Icon(Icons.person,
|
||||
size: 40, color: Colors.white),
|
||||
);
|
||||
}),
|
||||
),
|
||||
Positioned(
|
||||
bottom: -5,
|
||||
|
||||
Reference in New Issue
Block a user