【发布时间】:2021-06-10 21:25:59
【问题描述】:
我目前正在关注 Flutter 中的 ToDo-App 教程。使用“复选框”功能的代码(用于显示您是否已完成任务),我收到以下错误: 需要一个标识符。
这是代码:
import 'package:flutter/material.dart';
class Check extends StatelessWidget {
final bool? isActive;
const Check({Key? key, this.isActive}) : super(key: key);
@override
Widget build(BuildContext context) {
if (isActive ??){
return Container(
width: 30,
height: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.green,
),
child: Icon(
Icons.check,
size: 20,
color: Colors.white,
),
);
} else {
return Container(
width: 30,
height: 30,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: Icon(Icons.check, size: 20, color: Colors.white),
);
}
}
}
如果您能在这方面支持我,将不胜感激。我大多是 Flutter 的新手,并且到处搜索我能想到的如何解决这个问题,但找不到任何东西。
【问题讨论】:
标签: flutter dart identifier