import 'package:flutter/widgets.dart'; import 'chat_stack_disc.dart'; /// Where the chat stack sits in the chat on screen. The stack itself lives /// once above all the panes, so it keeps its state (and finishes folding) /// while the chat under it changes; the active chat marks its spot with a /// [ChatStackAnchorTarget] that the stack follows. class ChatStackAnchorScope extends InheritedWidget { const ChatStackAnchorScope({ super.key, required this.link, required super.child, }); /// The stack's link while this pane holds it; null for every other pane. final LayerLink? link; static LayerLink? of(BuildContext context) => context.dependOnInheritedWidgetOfExactType()?.link; @override bool updateShouldNotify(ChatStackAnchorScope oldWidget) => !identical(link, oldWidget.link); } /// The room the stack takes above a chat's composer: the transcript keeps /// its last line and its own floating controls clear of it. const double kChatStackClearance = kChatStackSlot + 12; /// The stack's slot in a chat's transcript area, bottom-end above the /// composer. class ChatStackAnchorTarget extends StatelessWidget { const ChatStackAnchorTarget({super.key, required this.link}); final LayerLink link; @override Widget build(BuildContext context) => CompositedTransformTarget( link: link, child: const SizedBox.square(dimension: kChatStackSlot), ); }