buildLeading method
Implementation
Widget buildLeading(BuildContext context, WidgetRef ref, {bool? expanded}) {
switch (this) {
case ModuleNode():
return Tooltip(
message: 'Module',
waitDuration: const Duration(milliseconds: 240),
child: ElementTileIcons.module.icon,
);
case FolderNode():
return (expanded ?? isExpanded
? ElementTileIcons.folderOpen
: ElementTileIcons.folder)
.icon;
case ComponentNode(:final component):
Widget icon = Tooltip(
message: [
'Component',
if (!kReleaseMode && component.meta.warnings.isNotEmpty)
...component.meta.warnings.map((e) => '• $e'),
].join('\n'),
waitDuration: const Duration(milliseconds: 240),
child: !kReleaseMode && component.meta.warnings.isNotEmpty
? ElementTileIcons.warning.icon
: ElementTileIcons.component.icon,
);
for (final addon
in ref.watch(addonsProvider).whereType<EditorAddon>()) {
icon = addon.visitComponentIcon(context, component, icon) ?? icon;
}
return icon;
case DocumentationNode():
return Tooltip(
message: 'Documentation Entry',
waitDuration: const Duration(milliseconds: 240),
child: ElementTileIcons.document.icon,
);
case StoryNode(:final component, :final story):
Widget icon = Tooltip(
message: 'Component Story or Scenario',
waitDuration: const Duration(milliseconds: 240),
child: ElementTileIcons.story.icon,
);
for (final addon
in ref.watch(addonsProvider).whereType<EditorAddon>()) {
icon = addon.visitStoryIcon(context, component, story, icon) ?? icon;
}
return icon;
default:
return const SizedBox.shrink();
}
}