MaybeWidget<T extends Object>.offstage constructor
const
MaybeWidget<T extends Object>.offstage (})
Creates a MaybeWidget that uses Offstage as the default orElse
widget.
This constructor is useful when you want to preserve the layout space even
when the value is null, but make the widget invisible.
valueis the value to check fornull._builderis the builder function to call with a non-nullvalue.orElsedefaults to Offstage whenvalueisnull.buildWhenoptional predicate; if provided and returnstruethe builder runs, if it returnsfalseorElse(the Offstage widget unless overridden) is used. When omitted only the null-check is applied.keyis the key for the widget.
Example:
MaybeWidget.offstage(
nullableValue,
(value) => Text(value.toString()),
)
Implementation
const MaybeWidget.offstage(
this.value,
this._builder, {
this.orElse = const Offstage(),
this.buildWhen,
super.key,
});