如何才能更正确地编写下图中标记的代码块。我的目标是如果availableColors变量为 null ,则将默认值发送到参数。
showDialog<Color>(
context: context,
builder: (BuildContext context) {
return OrientationBuilder(
builder: (context, orientation) {
return ResponsiveDialog(
context: context,
title: title,
headerColor: headerColor,
headerTextColor: headerTextColor,
backgroundColor: backgroundColor,
buttonTextColor: buttonTextColor,
child: availableColors == null ? BlockPicker(
pickerColor: selectedColor,
onColorChanged: (color) => selectedColor = color,
): BlockPicker(
pickerColor: selectedColor,
availableColors: availableColors,
onColorChanged: (color) => selectedColor = color,
),
okPressed: () => Navigator.of(context).pop(selectedColor),
);
},
);
},
).then((selection) {
if (onChanged != null && selection != null) onChanged(selection);
}); …
Run Code Online (Sandbox Code Playgroud)