Avatar
An avatar identifies a person in a small space. Initials give the reader a recognizable fallback when a photo is unavailable.
Switch reviewers
#Switch between Ana Lee and Jo Ray. Compare the initials on the avatar with the full name beneath it.
components/avatar/appliance/switch_reviewer.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class SwitchReviewer extends StatefulWidget {
const SwitchReviewer({super.key});
@override
State<SwitchReviewer> createState() => _SwitchReviewerState();
}
class _SwitchReviewerState extends State<SwitchReviewer> {
bool ana = true;
@override
Widget build(BuildContext context) {
final name = ana ? 'Ana Lee' : 'Jo Ray';
return ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 440),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ApplianceAvatar(name: name),
const SizedBox(height: 12),
Text(name),
const SizedBox(height: 12),
ApplianceButton(
'Switch reviewer',
onPressed: () => setState(() => ana = !ana),
),
],
),
);
}
}
Parameters
ApplianceAvatar API ↗name- Names the person and supplies the fallback initials where supported.
slotId- Identifies the named image slot used to resolve the picture.
size- Its diameter.
style- Its style, over ApplianceThemeData.avatarStyle.
Shared behaviour
- Keyboard and focus. Tab to Switch reviewer to change the person. The identity marker itself takes no action.
- Screen readers. Read the full name and compare it with the name the avatar exposes. The caption changes with the initials.
- Direction and type. Initials stay in their usual order in RTL. Try 200% and compare the compact face with the full-size name.