PromptScope class

An inherited widget that abstracts prompt completion and lifecycle controls, shielding descendant widgets from any low-level/internal event buses.

Example:

class MySubmitButton extends Widget {
  @override
  void render(Buffer buffer, Rect area) { ... }

  bool handleKeyEvent(KeyEvent event) {
    if (event.key == 'enter') {
      PromptScope.of(context)?.done('submitted_value');
      return true;
    }
    return false;
  }
}
Inheritance

Constructors

PromptScope({required void onDone(Object? result), required Widget child})
Creates a PromptScope with the given onDone callback and child.
const

Properties

child → Widget
The widget below this widget in the tree.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
The optional key for this widget.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() → Element
Creates an Element to manage this widget's location in the tree.
inherited
done([Object? result]) → void
Programmatically completes the current prompt, returning an optional result.
getIntrinsicHeight(int width) → int
Computes the intrinsic height of this widget under the given width constraint.
inherited
getIntrinsicWidth(int height) → int
Computes the intrinsic width of this widget under the given height constraint.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
updateShouldNotify(covariant PromptScope oldWidget) → bool
Whether the framework should notify widgets that inherit from this widget.
override

Operators

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

Static Methods

of(BuildContext context) → PromptScope?
Obtains the nearest PromptScope from the build context.