4

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'),
    ),
  ),
);
Omar Fayad
  • 1,733
  • 3
  • 11
  • 27

1 Answers1

1

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.

Omar Fayad
  • 1,733
  • 3
  • 11
  • 27
  • Back button stops working after routing a few times (`WillPopScope`, returning to previous route and exiting app) on `Flutter 1.22.0-10.0.pre.82 • channel master`, switching to `Flutter 1.20.3 • channel stable` fixed the issue. – Michael DiCioccio Sep 04 '20 at 13:19