gpt4 book ai didi

flutter - 使用GlobalKey触发另一个状态功能

转载 作者:行者123 更新时间:2023-12-03 04:00:42 25 4
gpt4 key购买 nike

重现错误的基本应用有两个小部件

主页小部件包含一个手势检测器,可触发以下功能:

GlobalKey<MainMapState> mapKey = GlobalKey<MainMapState>();

void getCurrentLocation() async{ // I am using async property for something different but it not our concern right now
mapKey.currentState.asdd();
}

MainMap是一个有状态的小部件,其状态包含以下功能:
void asdd(){
print("triggered");
}

结果,我得到了这个 error

注意:我正在使用GlobalKey将CameraPosition动画化为MainMapState内部的GoogleMap小部件上的当前位置

最佳答案

抱歉,我没有足够的声誉积分,只能对您的帖子发表评论。

根据您收到的错误,我怀疑您遇到的问题与我尚未找到正确答案的问题相同。如链接所示,在我的同一问题上列出了几种替代方法:

How to smoothly update a Flutter AnimatedList without using a GlobalKey.currentState?

关于flutter - 使用GlobalKey触发另一个状态功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57169320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com