classify method
Implementation
@override
NotchInfo classify(SystemInfo info, {Orientation? orientation}) {
final effectiveOrientation = orientation ?? info.orientation;
final notchInfo = baseClassifier.classify(info, orientation: effectiveOrientation);
final cutoutRects = <ui.Rect>[];
Rect? hingeBounds;
FoldState? foldState;
for (final feature in info.displayFeatures) {
switch (feature.type) {
case ui.DisplayFeatureType.cutout:
cutoutRects.add(feature.bounds);
case ui.DisplayFeatureType.hinge:
case ui.DisplayFeatureType.fold:
hingeBounds = feature.bounds;
switch (feature.state) {
case ui.DisplayFeatureState.postureFlat:
foldState = FoldState.flat;
case ui.DisplayFeatureState.postureHalfOpened:
foldState = FoldState.halfOpened;
default:
foldState = FoldState.unknown;
}
default:
break;
}
}
if (cutoutRects.isEmpty && hingeBounds == null && foldState == null) {
foldState = FoldState.unknown;
}
return NotchInfo(
type: notchInfo.type,
topInset: notchInfo.topInset,
bottomInset: notchInfo.bottomInset,
leftInset: notchInfo.leftInset,
rightInset: notchInfo.rightInset,
cutoutRects: cutoutRects.isNotEmpty ? cutoutRects : notchInfo.cutoutRects,
foldState: foldState ?? notchInfo.foldState,
hingeBounds: hingeBounds ?? notchInfo.hingeBounds,
orientation: effectiveOrientation,
);
}