Navigator.pop(context,result) 错误:类型 'user' 不是 'result' 类型的 'bool?' 的子类型



我想通过关闭navigator.pop(context,result(接口来传递对象,但我有这个错误

=====手势捕捉到异常===============================================================处理手势时引发了以下_TypeError:类型"User"不是类型"bool?"的子类型"结果"的

当抛出异常时,这是堆栈:#0 LocalHistoryRoute.didPop(包:flutter/src/widgets/routes.dart(#1_RouteEntry.handlePop(包:flutter/src/widgets/navigator.dart:2896:16(#2 NavigatorState_flushHistoryUpdates(包:flutter/src/widgets/navigator.dart:3868:22(#3 NavigatorState.pop(包:flutter/src/widgets/navigator.dart:4910:7(#4 Navigator.pop(包:flutter/src/widgets/Navigator.dart:2432:27(#5 _DistributeurListState.build..(包:electrosteel_project/widget/point_de_vente/distributeur_list.dart:312:39(#6 _确认响应状态_handleTap(包装:flutter/src/material/ink_well.dart:1005:21(#7手势识别器.invokeCallback(软件包:flutter/src/sgestures/identifier.dart:198:24(#8 TapGestureRecognizer.handleTapUp#9 BaseTapGestureRecognizer_checkUp(软件包:flutter/src/sgestures/tap.dart:298:5(#10 BaseTapGestureRecognizer.acceptGesture(软件包:flutter/src/sgestures/tap.dart:269:7(#11手势ArenaManager.sweep(包:flutter/src/sgestures/arena。dart:157:27(#12 GestureBinding.handleEvent(包:flutter/src/sgestures/binding.dart:449:20(#13 GestureBinding.dispatchEvent(包:flutter/src/sgestures/binding.dart:425:22(#14 RendererBinding.dispatchEvent(包:flutter/src/rendering/binding.dart:329:11(#15手势绑定_handlePointerEvent立竿见影(软件包:flutter/src/sgestures/binding.dart:380:7(#16GestureBinding.handlePointerEvent(包:flutter/src/sgestures/binding.dart:344:5(#17手势绑定_flushPointerEventQueue(软件包:flutter/src/sgestures/binding.dart:302:7(#18手势绑定_handlePointerDataPacket(包:flutter/src/sportions/binding.dart:285:7(#22_invoke1(省道:ui/钩。省道:170:10(#23 PlatformDispatcher_dispatchPointerDataPacket(dart:ui/platform_dispatcher.dart:331:7(#24 _dispatchPointerDataPacket(dart:ui/hooks.dart:94:31((从dart:async中删除了3帧(经办人:"onTap";识别器:TapGestureRecognizer#b4118debugOwner:手势检测器状态:就绪获胜的竞技场最终位置:偏移(150.9333.7(finalLocalPosition:偏移(150.9,93.0(按钮:1发送点击下降

onTap: () {
Navigator.pop(context,userList[index]);
},

您正在将PointdeVente对象分配给bool对象

我想你用的是这样的

bool? result = await Navigator.of(context).pushNamed(YourScreen.route):

YourScreen中,你像这样弹出

Navigator.pop(context,PointdeVente());

你必须这样做。示例:

PointdeVente? result = await Navigator.of(context).pushNamed(YourScreen.route):

如果你期待PointdeVente,那么你应该在YourScreen中像这样弹出

Navigator.pop(context,PointdeVente());

相关内容

最新更新