AudioGrid class

A stateless widget rendering audio-only participant cards in a Stack layout.

Displays multiple AudioCard components layered on top of each other using Stack, allowing overlap and custom positioning. Typically used for audio-only meetings or when video is disabled for multiple participants.

Rendering Logic:

  1. Iterates through componentsToRender list
  2. For each component, calls itemBuilder (if provided) to wrap it
  3. Collects all items into list
  4. Creates Stack with items, applying alignment and clipBehavior
  5. Calls containerBuilder (if provided) to wrap Stack

Layout Structure:

Stack (containerBuilder)
  ├─ alignment: AlignmentDirectional.topStart (default)
  ├─ clipBehavior: Clip.hardEdge (default)
  └─ children:
     ├─ Component[0] (itemBuilder) [bottom layer]
     ├─ Component[1] (itemBuilder)
     └─ Component[N] (itemBuilder) [top layer]

Builder Hook Priorities:

  • itemBuilder: Called once per component; receives index, component, defaultItem
  • containerBuilder: Called once for entire Stack; receives items list, defaultContainer

Common Use Cases:

  1. Basic Audio Participant Stack:

    AudioGrid(
      options: AudioGridOptions(
        componentsToRender: audioParticipants.map((participant) {
          return AudioCard(
            options: AudioCardOptions(
              name: participant.name,
              participant: participant,
              parameters: parameters,
              customStyle: BoxDecoration(
                color: Colors.grey[800],
                borderRadius: BorderRadius.circular(8),
              ),
            ),
          );
        }).toList(),
      ),
    )
    
  2. Audio Grid with Padding:

    AudioGrid(
      options: AudioGridOptions(
        componentsToRender: audioCards,
        itemBuilder: (context) {
          return Padding(
            padding: EdgeInsets.all(4),
            child: context.defaultItem,
          );
        },
      ),
    )
    
  3. Centered Audio Display:

    AudioGrid(
      options: AudioGridOptions(
        componentsToRender: audioCards,
        alignment: Alignment.center,
        containerBuilder: (context) {
          return Container(
            decoration: BoxDecoration(
              gradient: LinearGradient(
                colors: [Colors.black, Colors.grey[900]!],
              ),
            ),
            child: context.defaultContainer,
          );
        },
      ),
    )
    
  4. Indexed Item Styling:

    AudioGrid(
      options: AudioGridOptions(
        componentsToRender: audioCards,
        itemBuilder: (context) {
          // Style first item differently
          if (context.index == 0) {
            return Container(
              decoration: BoxDecoration(
                border: Border.all(color: Colors.blue, width: 2),
              ),
              child: context.defaultItem,
            );
          }
          return context.defaultItem;
        },
      ),
    )
    

Override Integration: Integrates with MediasfuUICustomOverrides for global styling:

overrides: MediasfuUICustomOverrides(
  audioGridOptions: ComponentOverride<AudioGridOptions>(
    builder: (existingOptions) => AudioGridOptions(
      componentsToRender: existingOptions.componentsToRender,
      alignment: Alignment.topCenter,
      clipBehavior: Clip.antiAlias,
      itemBuilder: (context) {
        return Container(
          margin: EdgeInsets.all(8),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(12),
            boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 4)],
          ),
          child: context.defaultItem,
        );
      },
    ),
  ),
),

Stack Layering:

  • Components rendered in order: first = bottom, last = top
  • Each component fills Stack space based on its own constraints
  • Alignment affects how each child positions within Stack
  • Overlapping creates layered effect (useful for compact audio displays)

Performance Notes:

  • Stateless widget (no internal state)
  • List.generate creates items list once per build
  • Builder hooks called during build (not cached)
  • Stack renders all children (no lazy loading)
  • Suitable for small-to-medium participant counts (2-20 typically)

Implementation Details:

  • Uses List.generate to iterate componentsToRender
  • itemBuilder receives AudioGridItemContext with index and component
  • containerBuilder receives AudioGridContainerContext with all items
  • Default Stack uses alignment and clipBehavior from options
  • No positioning logic (Stack handles layout automatically)

Typical Usage Context:

  • Audio-only meetings
  • Participants with video disabled
  • Compact display of multiple audio participants
  • Fallback when video grid capacity exceeded
Inheritance

Constructors

AudioGrid({Key? key, required AudioGridOptions options})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
options AudioGridOptions
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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