AudioCardOptions class

Configuration options for the AudioCard widget.

Provides properties to customize the audio-only participant card display, including mini-card avatar, animated waveform bars, mute controls, and overlay styling.

Core Display Properties:

  • name: Participant display name
  • participant: Participant model (used for mute state, audio level, permissions)
  • parameters: AudioCardParameters providing runtime state (audioDecibels, socket, etc.)
  • customStyle: BoxDecoration for outer container (background, border, etc.)
  • backgroundColor: Fallback background color (default: Colors.white)

Audio Visualization:

  • barColor: Waveform bar color (default: red); animated based on audio levels
  • showInfo: If true, displays participant name badge (default: true)
  • showControls: If true, shows mute toggle button (default: true)

Avatar/Image Props:

  • imageSource: Optional participant image URL for MiniCard avatar
  • roundedImage: If true, renders circular avatar (default: false)
  • imageStyle: BoxDecoration for avatar container
  • textColor: Name badge text color (default: white)

Controls/Info Positioning:

  • controlsPosition: Mute button placement: 'topLeft', 'topRight', 'bottomLeft', 'bottomRight' (default: 'topLeft')
  • infoPosition: Name badge placement: same options (default: 'topRight')
  • videoInfoComponent: Custom widget override for info area (replaces name badge)
  • videoControlsComponent: Custom widget override for controls area (replaces mute button)

Mute Control:

  • controlUserMedia: Function handling mute/unmute actions; default=controlMedia
    • Checks host/coHost permissions via coHostResponsibility
    • Sends socket events to mute remote participants
    • Only host/coHost with media permission can mute others

Builder Hooks (5):

  • customBuilder: Full widget replacement; receives AudioCardOptions
  • wrapperBuilder: Override Stack wrapper; receives stackChildren + default
  • containerBuilder: Override Container; receives child + default
  • infoBuilder: Override name badge overlay; receives overlay + default
  • overlayBuilder: Override waveform overlay; receives waveform + default
  • waveformBuilder: Override animated bars; receives animationControllers + default

Styling Properties:

  • containerPadding/containerMargin/containerAlignment: Outer container layout
  • overlayDecoration: BoxDecoration for waveform overlay layer
  • overlayPadding: Padding for overlay content

Usage Patterns:

  1. Basic Audio Card:

    AudioCard(
      options: AudioCardOptions(
        name: 'John Doe',
        participant: participant,
        parameters: parameters,
        customStyle: BoxDecoration(color: Colors.grey[800], borderRadius: BorderRadius.circular(8)),
      ),
    )
    
  2. Custom Waveform Colors:

    AudioCard(
      options: AudioCardOptions(
        name: 'John Doe',
        participant: participant,
        parameters: parameters,
        barColor: Colors.green,
        customStyle: BoxDecoration(color: Colors.black),
      ),
    )
    
  3. Hide Controls (View-Only):

    AudioCard(
      options: AudioCardOptions(
        name: 'John Doe',
        participant: participant,
        parameters: parameters,
        showControls: false,
      ),
    )
    
  4. Builder Hook Override:

    AudioCard(
      options: AudioCardOptions(
        name: 'John Doe',
        participant: participant,
        parameters: parameters,
        infoBuilder: (context, overlay, defaultInfo) {
          return Column(
            children: [
              Text('Custom Header'),
              defaultInfo,
            ],
          );
        },
      ),
    )
    

Override Integration: Integrates with MediasfuUICustomOverrides for global styling:

overrides: MediasfuUICustomOverrides(
  audioCardOptions: ComponentOverride<AudioCardOptions>(
    builder: (existingOptions) => AudioCardOptions(
      name: existingOptions.name,
      participant: existingOptions.participant,
      parameters: existingOptions.parameters,
      customStyle: BoxDecoration(border: Border.all(color: Colors.blue, width: 2)),
      barColor: Colors.cyan,
    ),
  ),
),

Waveform Animation:

  • Displays 9 animated bars representing audio levels
  • Bar heights animate based on audioDecibels from parameters.audioDecibels
  • Animation controllers created in State (1 per bar)
  • Bars hidden if participant muted or no audio detected

Permission-Based Mute:

  • Host (islevel='2') can always mute others
  • CoHost (islevel='1') can mute if coHostResponsibility includes media permission
  • Participants (islevel='0') can only mute themselves
  • Socket event 'controlMedia' emitted when muting remote participants

Constructors

AudioCardOptions.new({ControlMediaType controlUserMedia = controlMedia, required BoxDecoration customStyle, required String name, Color barColor = const Color.fromARGB(255, 240, 35, 35), Color textColor = Colors.white, String? imageSource, bool roundedImage = false, BoxDecoration? imageStyle, bool showControls = true, bool showInfo = true, Widget? videoInfoComponent, Widget? videoControlsComponent, String controlsPosition = 'topLeft', String infoPosition = 'topRight', required Participant participant, Color backgroundColor = Colors.white, required AudioCardParameters parameters, AudioCardType? customBuilder, EdgeInsetsGeometry? containerPadding, EdgeInsetsGeometry? containerMargin, AlignmentGeometry? containerAlignment, BoxDecoration? overlayDecoration, EdgeInsetsGeometry? overlayPadding, AudioCardWrapperBuilder? wrapperBuilder, AudioCardContainerBuilder? containerBuilder, AudioCardInfoBuilder? infoBuilder, AudioCardOverlayBuilder? overlayBuilder, AudioCardWaveformBuilder? waveformBuilder, double borderRadius = 0.0, bool enableGlassmorphism = false, bool showStatusIndicator = false, bool isDarkMode = false, Gradient? backgroundGradient, ValueListenable<LiveSubtitle?>? liveSubtitle, bool showSubtitles = false, ValueListenable<bool>? showSubtitlesNotifier})

Properties

backgroundColor → Color
final
backgroundGradient → Gradient?
Optional background gradient. Used by modern styling.
final
barColor → Color
final
borderRadius → double
Border radius for the audio card. Used by modern styling for rounded corners.
final
containerAlignment → AlignmentGeometry?
final
containerBuilder → AudioCardContainerBuilder?
final
containerMargin → EdgeInsetsGeometry?
final
containerPadding → EdgeInsetsGeometry?
final
controlsPosition → String
final
controlUserMedia → ControlMediaType
final
customBuilder → AudioCardType?
final
customStyle → BoxDecoration
final
enableGlassmorphism → bool
Enable glassmorphism effects. Used by modern styling for blur effects.
final
hashCode → int
The hash code for this object.
no setterinherited
imageSource → String?
final
imageStyle → BoxDecoration?
final
infoBuilder → AudioCardInfoBuilder?
final
infoPosition → String
final
isDarkMode → bool
Dark mode toggle. Used by modern styling for theme.
final
liveSubtitle → ValueListenable<LiveSubtitle?>?
Live subtitle for displaying translated speech. Used by modern styling for subtitle overlays.
final
name → String
final
overlayBuilder → AudioCardOverlayBuilder?
final
overlayDecoration → BoxDecoration?
final
overlayPadding → EdgeInsetsGeometry?
final
parameters → AudioCardParameters
final
participant → Participant
final
roundedImage → bool
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showControls → bool
final
showInfo → bool
final
showStatusIndicator → bool
Whether to show status indicator. Used by modern styling for status overlays.
final
showSubtitles → bool
Whether to show subtitles on this card (static boolean). For reactive updates, use showSubtitlesNotifier instead.
final
showSubtitlesNotifier → ValueListenable<bool>?
Reactive notifier for whether to show subtitles on this card. Takes precedence over showSubtitles if provided.
final
textColor → Color
final
videoControlsComponent → Widget?
final
videoInfoComponent → Widget?
final
waveformBuilder → AudioCardWaveformBuilder?
final
wrapperBuilder → AudioCardWrapperBuilder?
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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