Flutter: Exception using Navigator.of(context).pop();

Every time I use Navigator.of(context).pop(); to return to the previous view I always get the

Unhandled Exception: NoSuchMethodError: The method ‘call’ was called
on null.


However, the app successfully goes back to the previous view, but I don’t know why I always get this message that sometimes causes a crash. What could it be?

#0      _rootRunUnary (dart:async/zone.dart:1198:47)
#1      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#2      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#3      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#4      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#5      Future._completeWithValue (dart:async/future_impl.dart:529:5)
#6      Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#7      _rootRun (dart:async/zone.dart:1190:13)
#8 (dart:async/zone.dart:1093:19)
#9      _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#10     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#11     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#12     _startMicrotaskLoop<…>

I usually use an Inkwell associated with an icon to call the method. In example:

InkWell(onTap: () => Navigator.of(context).pop(), 

  child: Icon(Icons.chevron_left_rounded, color: Constants.COLOR_DEF, size: 30));

Stack Overflow Asked by Gianni Ottimista on December 31, 2020

2 Answers

2 Answers

Nevermind, found the problem.

Basically, when going from one page to another, I've always called "Navigator.of(context).push(new MaterialPageRoute)" passing also a callback function (if necessary). When that callback function is not passed (null) the error is thrown.

Thanks anyway to anyone who replied!

Correct answer by Gianni Ottimista on December 31, 2020

this error usually arrives when the Navigator.of(context).currentState is null

which means you don't have any Route below current route, so you can't pop the route. Check this do you have any route below this route or not??

Answered by Akshit Ostwal on December 31, 2020

Add your own answers!

Related Questions

Center a grouped bar chart in R (ggplot2)

2  Asked on December 20, 2021


Node js – public subfolder

1  Asked on December 20, 2021 by andres-darwin


Syntax error on getting multiple range VBA

0  Asked on December 20, 2021 by michael-norman


what can make my form not to see my input value

2  Asked on December 18, 2021 by michael-august


Regex Match/Wildcard

1  Asked on December 18, 2021 by ovenbakedpython


javascript async and await event listener: Pokemon

1  Asked on December 18, 2021 by jason-todd


Why do I want to use CRTP over simple template for static polymorphism?

2  Asked on December 18, 2021 by diveintoml


Check if string in path and do something

2  Asked on December 18, 2021


sql, delete duplicate records using an ID

2  Asked on December 18, 2021 by user12929912


Ask a Question

Get help from others!

© 2022 All rights reserved.