import 'package:flutter/widgets.dart'; /// Marks the content beside the destination rail. A wide window's content /// lays out in the width left beside the rail, so list and detail panes read /// that width ([windowWidth]) instead of the window's. Outside the scope (a /// phone, a route pushed over the shell) the window's own width applies. class ShellRailScope extends InheritedWidget { const ShellRailScope({ super.key, required this.shown, required this.bodyWidth, required super.child, }); /// Whether the rail is shown beside this content. final bool shown; /// The width beside the rail; null when no rail is shown. final double? bodyWidth; /// Whether the rail is shown beside [context]'s content. static bool isShown(BuildContext context) => context.dependOnInheritedWidgetOfExactType()?.shown ?? false; /// The width the panes of [context] lay out in: the body beside the rail, /// or else the window. static double windowWidth(BuildContext context) => context.dependOnInheritedWidgetOfExactType()?.bodyWidth ?? MediaQuery.sizeOf(context).width; @override bool updateShouldNotify(ShellRailScope oldWidget) => shown != oldWidget.shown || bodyWidth != oldWidget.bodyWidth; }