Dart 导航到其他页面
我在颤振应用程序中使用Datepicker Cupertiono:Dart 导航到其他页面,dart,flutter,Dart,Flutter,我在颤振应用程序中使用Datepicker Cupertiono: https://github.com/wuzhendev/flutter-cupertino-date-picker 有一个名为“onConfirm()”的方法,我试图将用户重定向到其他页面,但运气不好。 我试过了 但当这个返回语句被点击时,实际发生的是cupertino小部件关闭,什么也没发生。没有错误 当我尝试使用: return Navigator.pushNamed<bool>(
https://github.com/wuzhendev/flutter-cupertino-date-picker
有一个名为“onConfirm()”的方法,我试图将用户重定向到其他页面,但运气不好。
我试过了
但当这个返回语句被点击时,实际发生的是cupertino小部件关闭,什么也没发生。没有错误
当我尝试使用:
return Navigator.pushNamed<bool>(
ctx,
'/route/' + object.id.toString());
return Navigator.pushNamed(
ctx,
'/route/'+object.id.toString());
一些错误如下:
Performing hot restart...
Restarted application in 1 685ms.
I/flutter (20542): 112
E/flutter (20542): [ERROR:flutter/shell/common/shell.cc(188)] Dart Error: Unhandled exception:
E/flutter (20542): Looking up a deactivated widget's ancestor is unsafe.
E/flutter (20542): At this point the state of the widget's element tree is no longer stable. To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling
inheritFromWidgetOfExactType() in the widget's didChangeDependencies() method.
E/flutter (20542):
E/flutter (20542): #0 Element._debugCheckStateIsActiveForAncestorLookup.<anonymous closure> (package:flutter/src/widgets/framework.dart:3232:9)
E/flutter (20542): #1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:3241:6)
E/flutter (20542): #2 Element.ancestorStateOfType (package:flutter/src/widgets/framework.dart:3289:12)
E/flutter (20542): #3 Scaffold.of (package:flutter/src/material/scaffold.dart:935:42)
正在执行热重启。。。
在1685毫秒内重新启动应用程序。
I/颤振(20542):112
E/flatter(20542):[错误:flatter/shell/common/shell.cc(188)]省道错误:未处理的异常:
E/flatter(20542):查找停用小部件的祖先是不安全的。
E/flatter(20542):此时小部件元素树的状态不再稳定。要在dispose()方法中安全地引用小部件的祖先,请通过调用
在小部件的didChangeDependencies()方法中继承FromWidgeToFexactType()。
E/颤振(20542):
E/颤振(20542):#0元素。DebugCheckStates是活动的forancestorlookup。(包:flatter/src/widgets/framework.dart:3232:9)
E/flatter(20542):#1个元素。_debugCheckStateIsActiveForAncestorLookup(包:flatter/src/widgets/framework.dart:3241:6)
E/flatter(20542):#2 Element.ancestorStateOfType(包:flatter/src/widgets/framework.dart:3289:12)
E/颤振(20542):#3脚手架(包装:颤振/src/材料/脚手架。dart:935:42)
您应该使用
导航器。按
。
导入页面,例如:Import'/otherPage.dart'代码>
而不是改变你的路线
returnnavigator.pushreplacementname(ctx,/otherPage')代码>
到
不幸的是,这对我不起作用。对你有用吗?如果可能的话,我宁愿使用Navigator.pushNamed()而不是Navigator.push()。
Performing hot restart...
Restarted application in 1 685ms.
I/flutter (20542): 112
E/flutter (20542): [ERROR:flutter/shell/common/shell.cc(188)] Dart Error: Unhandled exception:
E/flutter (20542): Looking up a deactivated widget's ancestor is unsafe.
E/flutter (20542): At this point the state of the widget's element tree is no longer stable. To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling
inheritFromWidgetOfExactType() in the widget's didChangeDependencies() method.
E/flutter (20542):
E/flutter (20542): #0 Element._debugCheckStateIsActiveForAncestorLookup.<anonymous closure> (package:flutter/src/widgets/framework.dart:3232:9)
E/flutter (20542): #1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:3241:6)
E/flutter (20542): #2 Element.ancestorStateOfType (package:flutter/src/widgets/framework.dart:3289:12)
E/flutter (20542): #3 Scaffold.of (package:flutter/src/material/scaffold.dart:935:42)
return Navigator.push(context, 'otherClassName');