我正在编写一个自定义小部件的代码,我需要在特定条件下导航到另一个页面(ViewProfileWidget)。FlutterFlow似乎在预览/运行模式下编译和工作,但我仍然得到一个编译错误:
The method 'ViewProfileWidget' isn't defined for the type '_CustomWidgetState'. Try correcting the name to the name of an existing method, or defining a method named 'ViewProfileWidget'.
下面是抛出错误的代码:
void _onTap(int profileId) {
Navigator.pushReplacement<void, void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) =>
ViewProfileWidget(profileJson: {"field" : "value}),
),
);
}
我也试过用
Navigator.pushNamed()
因为我认为这对我来说也是一个很好的解决方案,但是由于一些我无法理解的原因,没有找到指定的路由
1条答案
按热度按时间2izufjch1#
在视图中似乎没有导入定义ViewProfileWidget的文件。您可以尝试导入它: