petsHero-AI/lib/shared/tab_selector_scope.dart
2026-03-12 14:30:19 +08:00

22 lines
592 B
Dart

import 'package:flutter/material.dart';
import 'widgets/bottom_nav_bar.dart';
/// Allows routes (e.g. progress screen) to request switching to a tab when popping.
class TabSelectorScope extends InheritedWidget {
const TabSelectorScope({
super.key,
required this.selectTab,
required super.child,
});
final void Function(NavTab) selectTab;
static TabSelectorScope? maybeOf(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<TabSelectorScope>();
}
@override
bool updateShouldNotify(TabSelectorScope old) => selectTab != old.selectTab;
}