resolveFluentPersonaState function
FluentPersonaState
resolveFluentPersonaState({
- String? name,
- Widget? primary,
- Widget? secondary,
- Widget? tertiary,
- Widget? quaternary,
- bool presenceOnly = false,
- FluentPersonaSize size = FluentPersonaSize.medium,
- FluentPersonaTextPosition textPosition = FluentPersonaTextPosition.after,
- FluentPersonaTextAlignment textAlignment = FluentPersonaTextAlignment.center,
- ImageProvider<
Object> ? image, - String? initials,
- Widget? icon,
- FluentAvatarColor color = FluentAvatarColor.neutral,
- FluentAvatarShape shape = FluentAvatarShape.circular,
- FluentAvatarActive active = FluentAvatarActive.unset,
- FluentPresenceStatus? status,
- bool outOfOffice = false,
Builds the state a persona will be styled and rendered from.
The first of the three-function recomposition contract, and the one that
composes: it builds a real FluentAvatar — or, with presenceOnly, a real
FluentPresenceBadge — at the size size names, and hands it on as opaque
content. Neither component's token table is duplicated anywhere in this
file; the Size axis only chooses a FluentAvatarSize or a
FluentPresenceBadgeSize.
primary defaults to name rendered as text, matching upstream. name is
deliberately not also handed to the composed avatar as a semantic label:
the primary line already carries it, and doing both makes a screen reader
announce the person twice.
Implementation
FluentPersonaState resolveFluentPersonaState({
String? name,
Widget? primary,
Widget? secondary,
Widget? tertiary,
Widget? quaternary,
bool presenceOnly = false,
FluentPersonaSize size = FluentPersonaSize.medium,
FluentPersonaTextPosition textPosition = FluentPersonaTextPosition.after,
FluentPersonaTextAlignment textAlignment = FluentPersonaTextAlignment.center,
ImageProvider<Object>? image,
String? initials,
Widget? icon,
FluentAvatarColor color = FluentAvatarColor.neutral,
FluentAvatarShape shape = FluentAvatarShape.circular,
FluentAvatarActive active = FluentAvatarActive.unset,
FluentPresenceStatus? status,
bool outOfOffice = false,
}) {
final firstLine = primary ?? (name == null ? null : Text(name));
final media = presenceOnly
? (status == null
? null
: FluentPresenceBadge(
status: status,
outOfOffice: outOfOffice,
size: size.presenceSize,
))
: FluentAvatar(
image: image,
initials: initials,
icon: icon,
color: color,
size: size.avatarSize,
shape: shape,
active: active,
status: status,
outOfOffice: outOfOffice,
);
return FluentPersonaState(
size: size,
presenceOnly: presenceOnly,
textPosition: textPosition,
textAlignment: textAlignment,
alignMediaToPrimaryLine: presenceOnly,
textLineCount: <Widget?>[
firstLine,
secondary,
tertiary,
quaternary,
].whereType<Widget>().length,
media: media,
primary: firstLine,
secondary: secondary,
tertiary: tertiary,
quaternary: quaternary,
);
}