Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Another exception was thrown: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3803 pos 12: '_history.isNotEmpty': is not true

Tags:

flutter

i used persistent_bottom_nav_bar library in my app. When i use Navigator to display a new screen then error show.

InkWell(
    onTap: () {
      Navigator.of(context).popUntil(ModalRoute.withName("previousjob"));
      Navigator.of(context).pushAndRemoveUntil(
        CupertinoPageRoute(
          builder: (BuildContext context) {
            return SettingMenu();
          },
        ),
        (_) => true,
      );
    },
like image 905
Tanzeem Iqbal Avatar asked Feb 04 '26 00:02

Tanzeem Iqbal


2 Answers

I solved the issue in my code. My issue is that I was called navigator pop twice in a particular situation which caused the error.

like image 54
Axes Grinds Avatar answered Feb 05 '26 14:02

Axes Grinds


This is my 1st answer so might not be very clear. But from what I understood while having this same problem is, you need to use push first before you can actually use pop.

You are using pop first so there is nothing into your history.

Try:

    InkWell(
        onTap: () {
          Navigator.of(context).pushNameed(ModalRoute.withName("previousjob"));
          Navigator.of(context).pushAndRemoveUntil(
            CupertinoPageRoute(
              builder: (BuildContext context) {
                return SettingMenu();
              },
            ),
            (_) => true,
          );
        },
like image 20
Ridham Desai Avatar answered Feb 05 '26 12:02

Ridham Desai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!