다음과 같은 에러가 나타났다.
The property 'width' can't be unconditionally accessed because the receiver can be 'null'.
Try making the access conditional (using '?.') or adding a null check to the target
해결 방법
int? count = 1;
void main() {
// will throw an error if count is null
print(count! * 2);
}
int? count = 1;
void main() {
// safe
print((count ?? 1) * 2);
}
int? count = 1;
void main() {
if(count != null) {
print(count! * 2);
} else {
print('count is null');
}
}