20 lines
668 B
Dart
20 lines
668 B
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:arcx/core/constants/app_defaults.dart';
|
|
import 'package:arcx/data/local/models/models.dart';
|
|
|
|
/// Resolves a profile avatar to a local file when present, otherwise the
|
|
/// default asset. Missing local files fall back safely (no FileImage crash).
|
|
ImageProvider resolveAvatarImage(UserProfile? profile) {
|
|
final path = profile?.avatarLocalPath?.trim();
|
|
if (profile?.avatarSource == AvatarSource.localFile &&
|
|
path != null &&
|
|
path.isNotEmpty &&
|
|
File(path).existsSync()) {
|
|
return FileImage(File(path));
|
|
}
|
|
return const AssetImage(AppDefaults.defaultAvatarAssetPath);
|
|
}
|