look ahead
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/// 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;
|
||||
}
|
||||
Reference in New Issue
Block a user