This repository has been archived on 2025-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
OpenContacts/lib/models/user_profile.dart
2023-04-30 13:39:09 +02:00

20 lines
No EOL
557 B
Dart

import 'package:contacts_plus/config.dart';
class UserProfile {
final String iconUrl;
UserProfile({required this.iconUrl});
factory UserProfile.fromMap(Map map) {
return UserProfile(iconUrl: map["iconUrl"]);
}
Uri get httpIconUri {
final fullUri = iconUrl.replaceFirst("neosdb:///", Config.neosCdnUrl);
final lastPeriodIndex = fullUri.lastIndexOf(".");
if (lastPeriodIndex != -1 && fullUri.length - lastPeriodIndex < 8) {
return Uri.parse(fullUri.substring(0, lastPeriodIndex));
}
return Uri.parse(fullUri);
}
}