DialogueBoxWidget class

A ready-to-use dialogue box that renders the current DialogueLine from a DialogueRunner with an optional typewriter animation.

Place this in a Stack, Overlay, or Positioned widget above your game canvas:

Stack(
  children: [
    GameWidget(game: myGame),
    Positioned(
      left: 16, right: 16, bottom: 16,
      child: DialogueBoxWidget(
        runner: runner,
        onTap: runner.advance,
        portraitBuilder: (char) => CharacterPortrait(name: char),
      ),
    ),
  ],
)

Tapping behaviour

  • First tap while typewriter is running → instantly reveals the full text.
  • Second tap (or first tap when typewriter is done) → calls onTap (typically runner.advance).
Inheritance

Constructors

DialogueBoxWidget({Key? key, required DialogueRunner runner, VoidCallback? onTap, BoxDecoration? boxDecoration, TextStyle? characterNameStyle, TextStyle? textStyle, double typewriterSpeed = 40.0, bool showContinueIndicator = true, Widget portraitBuilder(String character)?, EdgeInsets padding = const EdgeInsets.all(16), double height = 160, Widget? continueIndicator})
const

Properties

boxDecoration BoxDecoration?
Background / border decoration for the dialogue box.
final
characterNameStyle TextStyle?
Style for the character name heading.
final
continueIndicator Widget?
Replace the default blinking-arrow indicator with your own widget.
final
hashCode int
The hash code for this object.
no setterinherited
height double
Fixed height of the dialogue box.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onTap VoidCallback?
Callback invoked when the player taps to advance (after typewriter finishes). Typically runner.advance.
final
padding EdgeInsets
final
portraitBuilder Widget Function(String character)?
Optional portrait widget factory. Receives the current speaker name.
final
runner DialogueRunner
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showContinueIndicator bool
Whether to show a blinking arrow / indicator when typewriter is done.
final
textStyle TextStyle?
Style for the body text.
final
typewriterSpeed double
Characters per second for the typewriter effect. Set to 0 to disable.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<DialogueBoxWidget>
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