28 lines
703 B
Dart
28 lines
703 B
Dart
/// Provides the active bottom-nav tab index for [MainShell].
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ShellTabScope extends InheritedWidget {
|
|
const ShellTabScope({
|
|
super.key,
|
|
required this.index,
|
|
required super.child,
|
|
});
|
|
|
|
final int index;
|
|
|
|
static int of(BuildContext context) {
|
|
final scope = context.dependOnInheritedWidgetOfExactType<ShellTabScope>();
|
|
assert(scope != null, 'ShellTabScope not found');
|
|
return scope!.index;
|
|
}
|
|
|
|
static int? maybeOf(BuildContext context) {
|
|
return context.dependOnInheritedWidgetOfExactType<ShellTabScope>()?.index;
|
|
}
|
|
|
|
@override
|
|
bool updateShouldNotify(ShellTabScope oldWidget) => index != oldWidget.index;
|
|
}
|