PrismConnectionBanner class
A slim banner that appears while the app is offline and disappears the moment connectivity returns.
It respects a settle delay so a two-second network blip does not flash a
banner, and it announces itself with Assertiveness.polite so screen
readers hear the change without being interrupted mid-sentence.
Column(
children: [
PrismConnectionBanner(
source: () => Connectivity().onConnectivityChanged.map((r) => r != ConnectivityResult.none),
),
Expanded(child: content),
],
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PrismConnectionBanner
Constructors
- PrismConnectionBanner({Key? key, required PrismConnectionSource source, String offlineMessage = 'You are offline — changes will sync when you reconnect', String? onlineMessage, Duration onlineDuration = const Duration(seconds: 2), Duration settleDelay = const Duration(milliseconds: 700), bool assumeOnline = true, bool compact = false, String? retryLabel, VoidCallback? onRetry, EdgeInsetsGeometry? margin})
-
Creates a connection banner.
const
Properties
- assumeOnline → bool
-
Whether the widget starts in the online state.
final
- compact → bool
-
Renders a shorter, denser banner.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- margin → EdgeInsetsGeometry?
-
Outer margin; defaults to a small inset.
final
- offlineMessage → String
-
Message shown while offline.
final
- onlineDuration → Duration
-
How long the "reconnected" message stays visible.
final
- onlineMessage → String?
-
Optional message flashed briefly when connectivity returns.
final
- onRetry → VoidCallback?
-
Called when retry is tapped.
final
- retryLabel → String?
-
Label for the retry action shown while offline.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settleDelay → Duration
-
Delay before showing the offline state, dampening brief blips.
final
- source → PrismConnectionSource
-
Produces a stream of
true(online) /false(offline) events.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< PrismConnectionBanner> -
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