Flutter: Using Hero without Navigation - flutter

I have an app that uses a BottomNavigationBar to switch between two screens with their own navigation stack. I would like to use the Hero tag to create a custom transition between the two, but since I don't use navigation, but rather change the state to switch between screens, I'm not sure if this is possible at all.
Is there any way to recreate the transitions provided by Hero without using Navigator?

The Hero widget is not what you are looking for. Try the animations package made by the flutter team. Here the link to this package.
Is not easy to use, but get a try, or you can use the default Navigation built in.

Related

Flutter Hero with custom AnimationController or entirely custom overlay

Is it possible to implement a Hero Animation in flutter but instead of being controlled by Navigator, be controlled by a custom AnimationController.
This is for a use case needs to go inside another element rather than a new screen as is the case with Navigator.
Alternatively, is it possible to directly inject a widget into an overlay that is fixed permanently elsewhere on the screen preserving the state, logic and controllers of where it was initially declared.
Imagine I have content that changes on a page based on a certain user interaction but still should animate a transition of a sliver app bar as if a new screen has entered when it had not.
In laymen's terms, I want to declare a widget wherever I happen to declare it but not actually render there. IT should render instead in a targeted location but still maintain any state or controllers it obtained or inherited from the position in which it was actually declare.

Flutter Recreating the Hero Transition replacing Navigator with a custom Animator

Looking at the Flutter Hero Transition, it appears to move the tagged Widgets to an Overlay class that exists in all Navigator Widgets but sits above the main content in the stack.
If this is correct, it allows the Hero to widgets to still respond to the Route scope and its animators but exist above the actual route content. How is this actually done efficiently? Surely this involves taking an entire Widget and storing it in a state for the duration of the animation. That Widget still has to respond to intrinsic responses from its original position such as slivers responding to active scroll actions.
Recreating this could be done with state management but I wondered how the standard hero actually does this. It seems like Widgets are effectively duplicated and then conditionally rendered on the screen defaulting to the overlay during the route animation and swapping out the original widget with an Offstage or similar. Is this how it is done?
The reason for trying to understand it is the need to replicate this behaviour in situations where Navigator is not an effective use case for a transition taking place internally on a page. I built an accordion style navigator but still want a hero transition to take place on the AppBar / NavigationBar. I know that this could be done with Navigator but it doesn't suit the use case. I could also predefine the AppBar content for each internal navigator state of the accordion but that is a lot of additional code.

Flutter - How to preserve widgets with data and states, when navigating using the NavigationBar class

I'm using the NavigationBar class for the navigation through my app, but I have a problem, which is that I can't preserve the information on the screen when I'm navigating, so everything loads up again at the start of the screen. How should I do to preserve the screen even if I am in another screen so everything doesnt load up again?
You can use bloc for your state management.
Use states. There are a lot of options available like for example stateful widgets.

Flutter: Using expansion panel with navigator animate the AppBar when expansion panel is open

In one section of a client's app an expansion panel / accordion is used to open some content. At the same time the AppBar is supposed to animated as is a new route has been pushed but the new route's content should display in the body of the expansion panel.
I have been able to implement this by creating an entirely independent Widget and using a state management library but it is not a tidy solution.
I wondered if it is possible to use the App's main Navigator but not remove the current route's body. This cannot be done with a nested navigator either as the AppBar uses Hero tags that are not reflected between Navigator's.
Is there a simple way to achieve this without using entirely customised state management.
Flutter's in built Navigator, even Navigator 2.0, is well known to not be a particularly friendly interface to use, so I'd recommend the use of a community library that makes things easier.
Auto Route is a popular solution that I use personally and can attest to its quality. For your particular problem it offers navigation observers which you can register. You could use this to trigger the animation of your app bar when the new route is pushed.
It will be a little bit of effort to replace your current navigation with a new library but I'd imagine you'll end up with a cleaner solution at the end instead of customized state management.

In Flutter is there a way to have different navigation stacks

I come from react-native and I am used to using react navigation, which allows you to make different stacks each with different routes in them.
Flutter appears to work where you have to put all your routes in one file, is there no way to split them up?
My app has 3 main sections and each screen in a section would ideally share blocs, but I cant find a way to make each section independent of the other sections which means either all the screens must share all the blocs or none of them.
Maybe you want every screen in section possible have a Navigator of itself ?
Default Flutter using a Navigator in app and navigate with Navigator.of(...). An app can use more than one Navigator with Navigator Widget.
Nesting Navigators
Code sample