草庐IT

payingAttention

全部标签

flutter - 从外部函数更新小部件

我有一个异步函数,它在收到蓝牙信号时更新一个全局bool变量。每当我更改bool变量时,我都想更新一个小部件,但我不知道如何操作。boolpayingAttention=false;startListening()async{//codethatcheckscontinouslyif(thing){payingAttention=false;}if(otherThing){payingAttention=true;}}//...classPageTwoextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){ret

flutter - 从外部函数更新小部件

我有一个异步函数,它在收到蓝牙信号时更新一个全局bool变量。每当我更改bool变量时,我都想更新一个小部件,但我不知道如何操作。boolpayingAttention=false;startListening()async{//codethatcheckscontinouslyif(thing){payingAttention=false;}if(otherThing){payingAttention=true;}}//...classPageTwoextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){ret