Files
pipelines/app/lib/core/servers/server_context.dart
T

28 lines
930 B
Dart

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<ServerConnections> {
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<ServerContext>();
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(' · ');
}