OpenUrlWidget class

OpenUrlWidget is a simple wrapper widget which reacts to user input and tries to open the provided url.

You can define a callback which is triggered right before trying to open the url with the onTap method.

If an error occurs, an onError callback will be triggered with the BuildContext and the exception as an input parameter.

In case an error needs to be translated or localized, you can use the translateError callback which returns the string used as the error message, and accepts the context and exception as inputs.

In case you need to open a phone number to call or send sms, you can provide a new value for the uriType parameter. By default it is set to UriType.https which handles any https requests.

When an error happens, a modal sheet will be displayed with that particular error. By default that modal sheet will apply a safe area bottom padding, to stay away from device-specific intrusions. You can turn this behaviour off by setting the errorModalConfiguration to false.

Inheritance

Constructors

OpenUrlWidget.new({required Widget child, required String url, VoidCallback? onTap, dynamic onError(BuildContext, Exception)?, String translateError(BuildContext context, Exception)?, UriType uriType = UriType.https, ModalConfiguration errorModalConfiguration = const ModalConfiguration(), Key? key})
const

Properties

child Widget
The child widget
final
errorModalConfiguration ModalConfiguration
With configuration property you can set up how the ModalBottomSheet in the default implementation of onError will appear. It refers to the default ModalConfiguration, but doesn't show close button and allows more then one sheets.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onError → dynamic Function(BuildContext, Exception)?
Callback triggered in case an error occurs
final
onTap VoidCallback?
Callback executed before we actually open the url
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
translateError String Function(BuildContext context, Exception)?
Function used for translating/localizing errors
final
uriType UriType
The type of the uri request (defaults to https)
final
url String
The url to be opened
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