pictureFormEntry method
Widget
pictureFormEntry(
{ - String title = 'Picture',
- String subTitle = 'you can change the picture',
- String? defaultValue,
})
Implementation
Widget pictureFormEntry({
String title = 'Picture',
String subTitle = 'you can change the picture',
String? defaultValue,
}) {
bool hasImage =
(defaultValue != null && defaultValue.isNotEmpty) ||
selectedImage != null ||
selectedImageBytes != null;
return formEntry(
title: title,
subTitle: subTitle,
inputWidget: Container(
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.grey[200]!),
),
child: Column(
children: [
// Image Display Section
Container(
width: 120,
height: 120,
decoration: BoxDecoration(
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 8,
offset: Offset(0, 4),
),
],
),
child: hasImage
? CircleAvatar(
radius: 60,
backgroundImage: kIsWeb && selectedImageBytes != null
? MemoryImage(selectedImageBytes!)
: selectedImage != null
? FileImage(selectedImage!)
: CachedNetworkImageProvider(defaultValue!),
)
: CircleAvatar(
radius: 60,
backgroundColor: Colors.grey[100],
child: Icon(
Icons.person,
size: 50,
color: Colors.grey[400],
),
),
),
SizedBox(height: 24),
// Action Buttons Section
Row(
children: [
// Select/Change Button
Expanded(
child: ElevatedButton.icon(
onPressed: isEdit ? pickImage : null,
icon: Icon(
hasImage ? Icons.edit : Icons.add_a_photo,
size: 20,
),
label: Text(
hasImage ? 'Change Photo' : 'Add Photo',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: primaryActiveColor,
foregroundColor: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 2,
shadowColor: primaryActiveColor.withOpacity(0.3),
),
),
),
if (hasImage) ...[
SizedBox(width: 12),
// Remove Button
Expanded(
child: OutlinedButton.icon(
onPressed: isEdit ? removeProfilePicture : null,
icon: Icon(
Icons.delete_outline,
size: 20,
color: Colors.red[600],
),
label: Text(
'Remove',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Colors.red[600],
),
),
style: OutlinedButton.styleFrom(
padding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
side: BorderSide(color: Colors.red[300]!),
),
),
),
],
],
),
// Helper Text
if (!hasImage) ...[
SizedBox(height: 12),
Text(
'Upload a photo to personalize your profile',
style: TextStyle(color: Colors.grey[600], fontSize: 12),
textAlign: TextAlign.center,
),
],
],
),
),
);
}