Ein Avatar-Widget, das die beste verfügbare Datenquelle unter den bereitgestellten verwendet (Sozialbilder, Gravatar, Initialen des Namens, benutzerdefiniert)
Aus öffentlichen Paketdaten erstellte Orientierung.
Das avatars-Paket bietet einen flexiblen und intelligenten Avatar-Widget für Flutter, der basierend auf den bereitgestellten Daten automatisch die beste verfügbare Bildquelle – wie soziale Medienprofile, Gravatar, Namenanfangsbuchstaben oder ein benutzerdefiniertes Bild – auswählt. Es vereinfacht die Darstellung von Profilbildern durch nahtlose Behandlung der Fallback-Logik und sorgt für eine konsistente Darstellung von Benutzern in Apps. Ideal für Chat-Schnittstellen, Benutzerprofile und soziale Funktionen, reduziert es Boilerplate-Code und verbessert die Benutzererfahrung durch zuverlässige Anzeige der visuellen Identität.
Anwendungsfälle
Benutzerprofil wird angezeigt
Chat-Schnittstellen
Soziale Medien-Integration
Benutzerkarten für das Dashboard
Authentifizierungsflüsse
Hauptmerkmale
Automatische Bildquellenauswahl
Gravatar-Unterstützung
Name Anfangsfall-back
Benutzerdefinierte Bildüberschreibung
Plattformübergreifende Kompatibilität
Geeignet für
Apps mit Benutzerprofilen
Messaging- oder Chat-Anwendungen
Soziale Netzwerk-Funktionen
Dashboard-Oberflächen mit Benutzerdaten
Hinweise
Benötigt Internetzugang für externe Quellen wie Gravatar
Die Generierung von Initialen hängt von der Qualität der Namenseingabe ab
Eingeschränkte Anpassung über die grundlegende Gestaltung hinaus
Kann eine Caching-Strategie für die Leistung erfordern
Hängt von externen APIs für einige Quellen ab
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
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.