EnvBadge<E extends Enum> class
An overlay widget that displays the currently active environment as a persistent badge in a corner of its child.
Place EnvBadge anywhere in the tree where you want the badge to appear.
Typically you wrap MaterialApp or a top-level Scaffold so the badge is
always visible:
EnvBadge<Environment>(
child: MaterialApp(...),
)
The badge reacts automatically to environment switches via
EnvManager's ValueNotifier — no manual rebuilds needed.
Custom badge widget
EnvBadge<Environment>(
alignment: Alignment.bottomLeft,
badgeBuilder: (env) => Chip(label: Text(env.name.toUpperCase())),
child: MaterialApp(...),
)
Release-mode visibility
By default the badge is hidden in release builds. Set
visibleInRelease to true if you need it in production (e.g. for an
internal distribution build):
EnvBadge<Environment>(
visibleInRelease: true,
child: MaterialApp(...),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- EnvBadge
Constructors
- EnvBadge({Key? key, required Widget child, AlignmentGeometry alignment = Alignment.topRight, Widget badgeBuilder(E env)?, EdgeInsetsGeometry padding = const EdgeInsets.all(12), bool visibleInRelease = false})
-
Creates an EnvBadge.
const
Properties
- alignment → AlignmentGeometry
-
Corner alignment of the badge within the child. Defaults to
Alignment.topRight.
final
- badgeBuilder → Widget Function(E env)?
-
Optional builder for a custom badge widget.
final
- child → Widget
-
The widget tree over which the badge is overlaid.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- padding → EdgeInsetsGeometry
-
Padding between the badge and the edge of child.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- visibleInRelease → bool
-
Whether to show the badge in release mode. Defaults to
false.final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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