如果过期不为空,我想呈现文本小部件。所以我检查了 null
但是得到了错误
class TileButton extends StatelessWidget {
final DateTime? expires;
const TileButton({
Key? key,
this.expires,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
children: [
Text(
'Hello Flutter',
),
if (expires != null)
Text(
expires.day.toString(),
),
],
);
}
}