avatars 패키지는 제공된 데이터를 기반으로 소셜 미디어 프로필, 그라바타, 이름의 첫 글자 또는 사용자 지정 이미지와 같은 최적의 이미지 소스를 자동으로 선택하는 유연하고 지능적인 아바타 위젯을 제공합니다. 백업 로직을 원활하게 처리하여 앱 전반에서 사용자 표현의 일관성을 보장하며, 프로필 사진 렌더링을 간소화합니다. 채팅 인터페이스, 사용자 프로필 및 소셜 기능에 적합하며, 반복 코드를 줄이고 신뢰할 수 있는 시각적 정체성 표시를 통해 UX를 향상시킵니다.
사용 사례
사용자 프로필 표시
채팅 인터페이스
소셜 미디어 통합
대시보드 사용자 카드
인증 흐름
주요 기능
자동 이미지 소스 선택
Gravatar 지원
이름 초기 백업
사용자 지정 이미지 오버라이드
크로스 플랫폼 호환성
적합한 대상
사용자 프로필이 있는 앱
메시징 또는 채팅 애플리케이션
소셜 네트워킹 기능
사용자 데이터가 포함된 대시보드 UI
고려 사항
외부 리소스(예: Gravatar)를 위해 인터넷 연결이 필요합니다
초기 문자 생성은 이름 입력 품질에 따라 달라집니다
기본 스타일링을 넘어서는 사용자 정의가 제한적
성능을 위해 캐싱 전략이 필요할 수 있습니다
일부 소스는 외부 API에 의존합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
avatars
A complete avatar widget with a priority & fallback system which allows you to specify multiple image sources like socials (Facebook, Instagram, GitHub, Gravatar) and custom providers (assets and network) or to use text (name initials or custom values).
The widget will automatically find the best available image/text source among those provided.
Installation
In your pubspec.yaml file within your Flutter Project:
Using name property, the widget displays up to two initial letters found in the provided string.
Using value property, the widget displays the exact provided string.
Avatar's background is calculated from a default list of Color(). You can use a custom set of colors using placeholderColors:
An image source is an object used to generate, from local or remote sources, an ImageProvider() that will be used to show a picture inside the widget.
The sources list in Avatar() widget can contain multiple image sources: here, the priority & fallback system shows its power. If the first image source fails, the widget will try with the next one until a valid image source is found. If there are no sources available, the widget will use name or value data as seen in the previous example.
Here's the complete set of available image sources:
Socials
FacebookSource
Since Sep. 2020, to retrieve a user's profile picture by its ID from Facebook, you must make the request with an App Token or an Access Token.
You can find more details here.
GenericSource is generally used as a jolly image source: you can pass an ImageProvider() to show a picture.
GenericSource(ImageProvider image)
Shape, dimension, border and color
You can pass an AvatarShape() object to the widget using the shape property. The AvatarShape class provides two helper methods: circle(double radius) and rectangle(double width, double height, [BorderRadius borderRadius = BorderRadius.zero]).
This package uses flutter_cache_manager as dependency. The useCache set to true enables cache for every remote image request, improving performances. The default cache expiration is set to 7 days.