skip to Main Content

I’m building an application in flutter, I build two pages the main page and a configuration page, after that I added two buttons to the main page, one of then to navigate to the configuration page with this code:

void _gotoConfigurationPage() {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return const ConfigurationPage(title: 'ConfigurationPage');
    }));
  }

But when I try to debug the application in an Android emulator or an Android phone, the navigation doesn’t work, and the other buttons stop working, BUT when I open the application in the emulator or on the phone, the navigation works!

Am I doing something wrong?

===EDIT===

This is the code of the button in the main page used to navitate to the configuration page.

floatingActionButton: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          FloatingActionButton(
            onPressed: _gotoConfigurationPage,
            tooltip: 'Configuration',
            child: const Icon(Icons.settings),
          ),
          FloatingActionButton(
            onPressed: _action2,
            tooltip: 'Action2',
            child: const Icon(Icons.settings),
          ),
        ],
      ),

3

Answers


  1. Chosen as BEST ANSWER

    After some additional tests I realized some things, the first one was that the debugger get paused when I try to navigate and if I clicked in continue the application reach the configuration page, the second one was a message on console

    W/OnBackInvokedCallback( 6052): OnBackInvokedCallback is not enabled for the application.
    W/OnBackInvokedCallback( 6052): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
    

    after adding that on the manifest file in the console starts to appear another message

    Exception caught by scheduler library 
    
    There are multiple heroes that share the same tag within a subtree.
    

    with that in mind I found There are multiple heroes that share the same tag within a subtree, so I modified the buttons code and now the navigation works properly.


  2. I faced the same issue. I added debugShowCheckedModeBanner: false in the MaterialApp, ran flutter clean and flutter pub get, restarted vscode, and then ran the app.

    Login or Signup to reply.
  3. Just try doing a flutter clean.It would solve the issue

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search