displayFeatures property

List<DisplayFeature> get displayFeatures

The regions as Flutter DisplayFeatures: an active fold becomes a half-opened DisplayFeatureType.fold and a camera a DisplayFeatureType.cutout. Inactive folds are left out, because content may cross a flat fold. CNFoldableScope puts these into MediaQuery.displayFeatures, which Flutter's dialogs and popups already avoid.

Implementation

List<DisplayFeature> get displayFeatures => <DisplayFeature>[
  for (final r in regions)
    if (r.kind == CNReservedRegionKind.division && r.isActive)
      DisplayFeature(
        bounds: r.frame,
        type: DisplayFeatureType.fold,
        state: DisplayFeatureState.postureHalfOpened,
      )
    else if (r.kind == CNReservedRegionKind.occlusion && r.isActive)
      DisplayFeature(
        bounds: r.frame,
        type: DisplayFeatureType.cutout,
        state: DisplayFeatureState.unknown,
      ),
];