Files
TelemetryMonitor/lib/ui/app_scope.dart
2026-04-21 14:40:09 -03:00

39 lines
1.1 KiB
Dart

import 'package:flutter/widgets.dart';
import '../config/settings.dart';
import '../export/csv_exporter.dart';
import '../layout/layout_controller.dart';
import '../session/session_controller.dart';
/// Inherited widget that exposes the app's controllers to descendants.
///
/// Plain InheritedWidget rather than Provider/Riverpod, per the design
/// decision to avoid a state-management dependency.
class AppScope extends InheritedWidget {
const AppScope({
super.key,
required this.session,
required this.layout,
required this.settings,
required this.exporter,
required super.child,
});
final SessionController session;
final LayoutController layout;
final Settings settings;
final CsvExporter exporter;
static AppScope of(BuildContext context) {
final scope = context.dependOnInheritedWidgetOfExactType<AppScope>();
assert(scope != null, 'AppScope.of() called with no AppScope ancestor');
return scope!;
}
@override
bool updateShouldNotify(AppScope old) =>
session != old.session ||
layout != old.layout ||
settings != old.settings ||
exporter != old.exporter;
}