[bug]: replaceWithTransition doesn't work as expected
Opened this issue · 2 comments
Describe the bug
Hi,
I'm not sure if my implementation is wrong or if this is a bug
I'm using a bottomNavigationBar / Navigation rail to navigate to different screens. on the onTap / onDestinationSelected I pass the following function
void onDestinationSelected(int index) async {
setIndex(index);
switch (index) {
case 0:
await _navigationService.replaceWithTransition(const HomeView(),
transitionStyle: Transition.noTransition);
break;
case 1:
await _navigationService.replaceWithTransition(const MeetingsView(),
transitionStyle: Transition.noTransition);
break;
}
}
If I tap on the 2nd destination it shows me the MeetingsView which persists even if I tap on any other destinations. If I change the navigation service to use any other type of navigation the view changes.
void onDestinationSelected(int index) async {
setIndex(index);
switch (index) {
case 0:
await _navigationService.replaceWithHomeView();
break;
case 1:
await _navigationService.replaceWithMeetingsView();
break;
}
}
What operating system do you use?
macOS
Information about the installed tooling
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-IN)
• Flutter version 3.19.6 on channel stable at /Users/shalikhshab/FlutterDev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (2 weeks ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/shalikhshab/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
[✓] VS Code (version 1.89.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0
[✓] Connected device (3 available)
• shalikh’s iPhone (mobile) • 00008110-000529420261401E • ios • iOS 17.4.1 21E236
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.119
[✓] Network resources
• All expected network resources are available.
• No issues found!
Steps to reproduce the issue
https://github.com/shalikhshab00/hgec_mobile_app
- Make the device / simulator in landscape mode.
- Press "Login" button to navigate to home view.
- Try pressing home/meetings destination alternatively to see if the view changes. The code for making changes is in the 'widgets' folder having the name 'reusable_scaffold_with_bottom_nav'
- Logout has no functionality as of yet
Expected behavior
Change the views between destination with Transition set to Transition.noTransition
Screenshots
No response
Additional Context
No response
@shalikhshab00 you're mixing two implementations there, which looks a bit strange.
Since you're setting the index, you can simply replace your body with view you want without calling navigate.
Am I correct in saying you're using the index value to determine which view to show?
His implementation might be wrong but he's not wrong, I'm having this same issue too. Whenever I call navigateWithTransition nothing happens even if the function is evoked. However if I try the same with just navigateTo then it works flawlessly.
UPDATE: So apparently I need to pass in both the widget and the routeName for the animation to function, I'm not sure if it's intended to be this way or not