我正在尝试更新SpeedDialChild图标值的基础上一个布尔值。
final showCriticalPoint = useState(false);
SpeedDial(
isOpenOnStart: true,
closeManually: true,
renderOverlay: false,
closeDialOnPop: false,
direction: SpeedDialDirection.down,
backgroundColor: Colors.white,
activeIcon: Icons.close,
iconTheme: IconThemeData(color: themeData.colorScheme.secondary),
icon: Icons.menu_outlined,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
buttonSize: const Size(48, 48),
childrenButtonSize: const Size(48, 48),
spacing: 4,
children: [
SpeedDialChild(
child: Icon(
showCriticalPoint.value ? Icons.report_off_outlined : Icons.report_outlined,
color: Colors.white,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
backgroundColor: Colors.red,
onTap: () {
showCriticalPoint.value = !showCriticalPoint.value;
},
),
],
),
在儿童我想改变图标时,其轻敲
SpeedDialChild(
child: Icon(
showCriticalPoint.value ? Icons.report_off_outlined : Icons.report_outlined,
color: Colors.white,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
backgroundColor: Colors.red,
onTap: () {
showCriticalPoint.value = !showCriticalPoint.value;
},
),
1条答案
按热度按时间hjqgdpho1#
看起来快速拨号保留了上下文。
请执行以下操作,
这将强制快速拨号释放以前的上下文并在UI中呈现更新的值。