Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: replaceWithTransition doesn't work as expected #1102

Open
shalikhshab00 opened this issue May 5, 2024 · 1 comment
Open

[bug]: replaceWithTransition doesn't work as expected #1102

shalikhshab00 opened this issue May 5, 2024 · 1 comment

Comments

@shalikhshab00
Copy link

shalikhshab00 commented May 5, 2024

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

  1. Make the device / simulator in landscape mode.
  2. Press "Login" button to navigate to home view.
  3. 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'
  4. 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

@FilledStacks
Copy link
Contributor

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants