PrismMasterDetail<T> class

An adaptive master-detail layout.

On compact windows (phones) it shows the master list full-screen and presents the detail when an item is activated — either pushed onto the navigation stack (PrismCompactBehavior.push) or swapped in place (PrismCompactBehavior.replace). On medium and wider windows it shows both panes side by side, with keyboard navigation (arrow keys + Enter) on desktop.

PrismMasterDetail<Mail>(
  items: mails,
  masterBuilder: (context, mail, selected) => ListTile(
    selected: selected,
    leading: Icon(mail.icon),
    title: Text(mail.subject),
  ),
  detailBuilder: (context, mail) => MailView(mail: mail),
  empty: (context) => const Center(child: Text('Pick a message')),
)

Selection can be uncontrolled (default — the widget manages the selected index) or controlled via selectedIndex + onSelectionChanged.

Pure Flutter — no platform channels — works on Android, iOS, macOS, Windows, Linux, and web.

Inheritance

Constructors

PrismMasterDetail({Key? key, required List<T> items, required Widget masterBuilder(BuildContext context, T item, bool selected), required Widget detailBuilder(BuildContext context, T item), WidgetBuilder? empty, int? selectedIndex, ValueChanged<int?>? onSelectionChanged, PrismCompactBehavior compactBehavior = PrismCompactBehavior.push, double masterPaneWidth = 320, double? masterPaneWidthExtraLarge, Color? masterColor, Color? detailColor, Widget? divider, Duration? transitionDuration, bool autoFocus = false, bool debugCompactOverride = false})
Creates a master-detail layout.
const

Properties

autoFocus → bool
Whether the master list grabs keyboard focus on first build, enabling arrow-key/Enter navigation without an initial click. Off by default so the widget doesn't steal focus from text fields.
final
compactBehavior → PrismCompactBehavior
How the detail is presented on compact windows.
final
debugCompactOverride → bool
Forces compact layout even on wide windows — useful for previews and golden tests. Do not use in production code.
final
detailBuilder → Widget Function(BuildContext context, T item)
Builds the detail pane for the given item.
final
detailColor → Color?
Optional background color for the detail pane.
final
divider → Widget?
Divider drawn between the panes. Defaults to a thin border line.
final
empty → WidgetBuilder?
Shown in the detail pane when nothing is selected (wide windows only).
final
hashCode → int
The hash code for this object.
no setterinherited
items → List<T>
The items rendered in the master pane.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
masterBuilder → Widget Function(BuildContext context, T item, bool selected)
Builds one row in the master pane. selected is true for the item matching the current selection, so consumers can style it.
final
masterColor → Color?
Optional background color for the master pane.
final
masterPaneWidth → double
Width of the master pane on medium and expanded windows.
final
masterPaneWidthExtraLarge → double?
Optional wider master pane used on extra-large windows (1200px+). Falls back to masterPaneWidth when null.
final
onSelectionChanged → ValueChanged<int?>?
Called when the selection changes. With PrismCompactBehavior.replace on compact windows, the built-in back button reports null when the user dismisses the detail.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectedIndex → int?
Controls the selection externally. When null the widget manages its own selection state.
final
transitionDuration → Duration?
Duration of the detail-pane transition. Duration for animated transitions between panes. Defaults to PrismTokens.durationMedium.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<PrismMasterDetail<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited