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():
if (expanded ?? isExpanded) {
return ElementTileIcons.folderOpen.icon;
} else {
return ElementTileIcons.folder.icon;
}
case ComponentNode(:final component):
final addons = ref.watch(addonsProvider).whereType<ExplorerAddon>();
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 addons) {
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):
final addons = ref.watch(addonsProvider).whereType<ExplorerAddon>();
Widget icon = Tooltip(
message: 'Component Story or Scenario',
waitDuration: const Duration(milliseconds: 240),
child: ElementTileIcons.story.icon,
);
for (final addon in addons) {
icon = addon.visitStoryIcon(context, component, story, icon) ?? icon;
}
return icon;
default:
return const SizedBox.shrink();
}
}