navBarHeroFlightShuttleBuilder function
Navigation bars' hero flight shuttle builder.
Implementation
Widget navBarHeroFlightShuttleBuilder(
BuildContext flightContext,
Animation<double> animation,
HeroFlightDirection flightDirection,
BuildContext fromHeroContext,
BuildContext toHeroContext,
) {
assert(fromHeroContext.widget is Hero);
assert(toHeroContext.widget is Hero);
final Hero fromHeroWidget = fromHeroContext.widget as Hero;
final Hero toHeroWidget = toHeroContext.widget as Hero;
assert(fromHeroWidget.child is TransitionableNavigationBar);
assert(toHeroWidget.child is TransitionableNavigationBar);
final TransitionableNavigationBar fromNavBar =
fromHeroWidget.child as TransitionableNavigationBar;
final TransitionableNavigationBar toNavBar =
toHeroWidget.child as TransitionableNavigationBar;
assert(
fromNavBar.componentsKeys.navBarBoxKey.currentContext!.owner != null,
'The from nav bar to Hero must have been mounted in the previous frame',
);
assert(
toNavBar.componentsKeys.navBarBoxKey.currentContext!.owner != null,
'The to nav bar to Hero must have been mounted in the previous frame',
);
switch (flightDirection) {
case HeroFlightDirection.push:
return NavigationBarTransition(
animation: animation,
bottomNavBar: fromNavBar,
topNavBar: toNavBar,
);
case HeroFlightDirection.pop:
return NavigationBarTransition(
animation: animation,
bottomNavBar: toNavBar,
topNavBar: fromNavBar,
);
}
}