diagnostic_describe_all_properties
diagnostic_describe_all_properties
Diagnosticable을 구현하는 클래스에 debugFillProperties나 debugDescribeChildren 메서드로 설명되지 않은 public 프로퍼티가 있으면 이 진단이 나와요. Flutter에서 디버그 정보를 빠짐없이 보여주기 위해 필요한 규칙이죠. 어떻게 고치는지 살펴볼게요.
본문
Diagnosticable을 구현하는 클래스에 debugFillProperties나 debugDescribeChildren 메서드에서 프로퍼티로 추가되지 않은 public 프로퍼티가 있으면 analyzer가 이 진단을 만들어요.
예시
다음 코드는 프로퍼티 p2가 debugFillProperties 메서드에 추가되지 않아서 이 진단이 나와요.
import 'package:flutter/material.dart';
class const C({super.key}) extends Widget {
bool get p1 => true;
bool get p2 => false;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<bool>('p1', p1));
}
}
일반적인 해결 방법
debugFillProperties나 debugDescribeChildren 메서드의 override가 없다면 하나 추가해주세요. 그 메서드 안에서 해당 프로퍼티를 설명으로 추가하면 돼요.
import 'package:flutter/material.dart';
class const C({super.key}) extends Widget {
bool get p1 => true;
bool get p2 => false;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<bool>('p1', p1));
properties.add(DiagnosticsProperty<bool>('p2', p2));
}
}