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
-
- Object
- Widget
- InheritedWidget
- PromptScope
Constructors
- PromptScope({required void onDone(Object? result), required Widget child})
-
Creates a PromptScope with the given
onDonecallback andchild.const
Properties
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
widthconstraint.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Buffer buffer, Rect area) → void -
Renders the widget onto the provided
bufferwithin the specifiedarea.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.