Stack Overflow Asked by Gianni Ottimista on December 31, 2020
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.
message.
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 _CustomZone.run (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));
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
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP