草庐IT

flutter - 如何在 flutter 中刷新 UI?

我正在构建一个简单的小部件,我想及时更新它。classExampleextendsStatelessWidget{finalboolisWhite;Example(this.isWhite)Widgetbuild(BuildContextcontext){returnContainer(color:isWhite?Colors.white:Colors.black);}} 最佳答案 您需要使用StatefulWidget小部件并调用classExampleextendsStatefulWidget{@overrideStatecre

flutter - 如何在 flutter 中刷新 UI?

我正在构建一个简单的小部件,我想及时更新它。classExampleextendsStatelessWidget{finalboolisWhite;Example(this.isWhite)Widgetbuild(BuildContextcontext){returnContainer(color:isWhite?Colors.white:Colors.black);}} 最佳答案 您需要使用StatefulWidget小部件并调用classExampleextendsStatefulWidget{@overrideStatecre