bifold library
Fold awareness for Flutter apps on the foldable iPhone.
Wrap the app in a BifoldScope, then read the current state anywhere below
it with Bifold.of(context):
void main() => runApp(const BifoldScope(child: MyApp()));
// ...somewhere below:
final info = Bifold.of(context);
if (info.division != null) {
// The display is creased right now.
}
BifoldSplit lays two panes out on either side of the fold, and BifoldDebugOverlay draws the regions the platform is reporting so they can be seen rather than guessed at.
Two different questions have two different answers. What is the device
doing now is FoldInfo. What this device can ever do is
BifoldCapabilities, read with Bifold.capabilitiesOf(context):
if (Bifold.capabilitiesOf(context).hasHingeAngle) {
// Worth building a hinge-reactive UI on this device.
}
Keeping them apart matters. A foldable folded shut still has a fold, and a hinge sensor that is present but silent is a missing reading rather than a missing sensor.
On every platform without fold support — non-foldable phones, older iOS, iPad, web and desktop — this package reports FoldInfo.unsupported and BifoldCapabilities.none, and never throws.
Classes
- ArrangementMeasurement
- Where the platform's own split arrangement would place two panes.
- ArrangementPane
- One pane of a measured arrangement.
- Bifold
- Reads fold state from the widget tree.
- BifoldArrangement
- Asks the platform where it would place two panes.
- BifoldCapabilities
- What this device can do, as opposed to what it is doing right now.
- BifoldCapabilityFakes
- Ready-made BifoldCapabilities for tests and previews.
- BifoldCaptureAccessory
- Shows app content on the outer display while the camera is capturing.
- BifoldDebugOverlay
- Draws the reserved regions the platform is reporting, on top of child.
- BifoldDestination
- One navigation target in a BifoldScaffold.
- BifoldDisplayFeatures
- Republishes fold state as MediaQueryData.displayFeatures, so packages built for Android foldables work on this device too.
- BifoldGrid
- A grid whose rows stop cleanly at the fold instead of straddling it.
- BifoldPlatform
-
The interface every platform implementation of
bifoldsatisfies. - BifoldScaffold
- A scaffold that moves its navigation as the device folds.
- BifoldScope
- Supplies fold state to the widgets beneath it.
- BifoldSplit
- Lays two panes out on either side of the fold.
- CapabilityEvidence
- What is known about one capability, and where that knowledge came from.
- CapabilityResolver
- Combines capability reports over time into one answer.
- FakeBifoldPlatform
- A BifoldPlatform whose fold state and capabilities a test drives by hand.
- FoldInfo
- A complete description of the device's fold state at one moment.
- FoldInfoFakes
- Ready-made FoldInfo values for tests and previews.
- FoldRegion
- An area of the display claimed by hardware.
Enums
- ArrangementAxis
- Which way a split arrangement divides its box.
- BifoldSplitFallback
- What BifoldSplit does when there is no active division to split across.
- CapabilityStatus
- Whether the platform supports something, does not, or has not said yet.
- FoldDisplay
- Which physical display the app is currently presented on.
- FoldFeature
- A thing a device may or may not be able to do.
- FoldFormFactor
- The broad shape of a folding device.
- FoldPose
- How far the device is folded.
- FoldSizeClass
- A UIKit size class, as reported for the Flutter view.
- RearDisplayMode
- A way of putting app content on a display other than the main one.
- RegionKind
- What a FoldRegion represents.
- VerticalBarEdge
- Which edge the system places its vertical bar on.
Constants
- kBifoldPayloadVersion → const int
- The version of the platform channel payload this build of the package understands.
Functions
-
bifoldAnchorPoint(
BuildContext context) → Offset? - Keeps dialogs, popups and sheets off the fold.