NotchInfo.fromFoldable constructor
NotchInfo.fromFoldable({})
Implementation
factory NotchInfo.fromFoldable({
required SystemInfo info,
required NotchType type,
double topInset = 0,
double bottomInset = 0,
double leftInset = 0,
double rightInset = 0,
}) {
final cutoutRects = <ui.Rect>[];
for (final feature in info.displayFeatures) {
if (feature.type == ui.DisplayFeatureType.cutout) {
cutoutRects.add(feature.bounds);
}
}
FoldState? foldState;
bool foundFoldFeature = false;
for (final feature in info.displayFeatures) {
if (feature.type == ui.DisplayFeatureType.fold ||
feature.type == ui.DisplayFeatureType.hinge) {
foundFoldFeature = true;
switch (feature.state) {
case ui.DisplayFeatureState.postureFlat:
foldState = FoldState.flat;
case ui.DisplayFeatureState.postureHalfOpened:
foldState = FoldState.halfOpened;
default:
foldState = FoldState.unknown;
}
break;
}
}
if (!foundFoldFeature) {
foldState = FoldState.unknown;
}
return NotchInfo(
type: type,
topInset: topInset,
bottomInset: bottomInset,
leftInset: leftInset,
rightInset: rightInset,
cutoutRects: cutoutRects,
foldState: foldState,
hingeBounds: info.hingeBounds,
orientation: info.orientation,
);
}