import 'package:flutter/widgets.dart'; import '../../features/settings/server_connections.dart'; /// The machine owning this mounted app. A profile rename rebuilds consumers; /// changing machines creates a new gateway and app instead. class ServerContext extends InheritedNotifier { const ServerContext({ super.key, required ServerConnections connections, required this.serverId, required super.child, }) : super(notifier: connections); final String? serverId; static ServerContext? maybeOf(BuildContext context) => context.dependOnInheritedWidgetOfExactType(); String? get name { for (final server in notifier!.catalog.servers) { if (server.id == serverId) return server.name; } return null; } static String metadata(BuildContext context, String detail) => [?maybeOf(context)?.name, if (detail.isNotEmpty) detail].join(' ยท '); }