2
votes

I have no clue why this is happening. When device or emulator back button is pressed, nothing happens. App bar back button is working!, implemented back button works also.

I've created a new flutter project to test this problem:

First page

Scaffold(
  appBar: AppBar(
    title: Text(widget.title),
  ),
  body: Center(
    child: FlatButton(
      color: Colors.grey[300],
      onPressed: () {
        Navigator.push(
          context,
          MaterialPageRoute(
            builder: (context) => NextPage(),
          ),
        );
      },
      child: Text('next page'),
    ),
  ),
);

Second page

Scaffold(
  appBar: AppBar(
    title: Text('next page'),
  ),
  body: Center(
    child: FlatButton(
      color: Colors.grey[300],
      onPressed: () {
        Navigator.pop(context);
      },
      child: Text('go back'),
    ),
  ),
);
1
Did you tried in real Device? - Abir Ahsan
yes, both emulator and a physical device, same issue :( - Omar Fayad
There's nothing wrong with this code and it's working fine for me. Can you provide the full code? - Mobina
I'm also facing the same issue. i updated to the latest version of flutter master channel and then this issue occured. - theprasunranjan

1 Answers

1
votes

I used to be on master channel, I upgraded flutter today, and this issue came up. The solution was to change the channel to stable.

Run the command

Flutter channel stable

After it finishes run

Flutter clean

and everything should be alright.