I want to pass an object by closing the interface I did navigator.pop(context , result) but I have this error
======== Exception caught by gesture =============================================================== The following _TypeError was thrown while handling a gesture: type 'User' is not a subtype of type 'bool?' of 'result'
When the exception was thrown, this was the stack: #0 LocalHistoryRoute.didPop (package:flutter/src/widgets/routes.dart) #1 _RouteEntry.handlePop (package:flutter/src/widgets/navigator.dart:2896:16) #2 NavigatorState._flushHistoryUpdates (package:flutter/src/widgets/navigator.dart:3868:22) #3 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:4910:7) #4 Navigator.pop (package:flutter/src/widgets/navigator.dart:2432:27) #5 _DistributeurListState.build.. (package:electrosteel_project/widget/point_de_vente/distributeur_list.dart:312:39) #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:1005:21) #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:198:24) #8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:613:11) #9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:298:5) #10 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:269:7) #11 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27) #12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:449:20) #13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:425:22) #14 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:329:11) #15 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:380:7) #16 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:344:5) #17 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:302:7) #18 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:285:7) #22 _invoke1 (dart:ui/hooks.dart:170:10) #23 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:331:7) #24 _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31) (elided 3 frames from dart:async) Handler: "onTap" Recognizer: TapGestureRecognizer#b4118 debugOwner: GestureDetector state: ready won arena finalPosition: Offset(150.9, 333.7) finalLocalPosition: Offset(150.9, 93.0) button: 1 sent tap down
onTap: () {
Navigator.pop(context,userList[index]);
},
CodePudding user response:
You are assigning PointdeVente
object to bool
object
I think you're using like this
bool? result = await Navigator.of(context).pushNamed(YourScreen.route):
and in YourScreen
you pop like this
Navigator.pop(context,PointdeVente());
You have to do something like this. Example:
PointdeVente? result = await Navigator.of(context).pushNamed(YourScreen.route):
if you are expecting PointdeVente
then you should pop like this in YourScreen
Navigator.pop(context,PointdeVente());