ApiCallBuilder<T extends Decodable, E extends Decodable> class

This widget helps to manage transparently an API call in the widget tree showing a loading widget while performing the request and providing access to the response in the builder parameter, to show a proper widget on http call completion.

It must be used with the ConnectionManager, that is what manages API call and states through a bloc component.

T and E are, respectively, the class to decode in the success response and the class to decode for an error response. If not provided, the builder will have a generic Object as argument, that then should be casted to use.

Inheritance

Constructors

ApiCallBuilder({Key? key, required APIRequest<T, E> apiCall, required Widget builder(BuildContext context, T? response, List<T>? responseList), Widget child(Widget child)?, Widget loaderBuilder(BuildContext context)?, Widget errorBuilder(BuildContext context, String? errorMessage)?})
This widget helps to manage transparently an API call in the widget tree showing a loading widget while performing the request and providing access to the response in the builder parameter, to show a proper widget on http call completion.
const

Properties

apiCall APIRequest<T, E>
The api call to perform with the ConnectionManager. It is the same apicall with doApiRequest that is normally performmed by the ConnectionManager
final
builder Widget Function(BuildContext context, T? response, List<T>? responseList)
The builder for a widget when the API call is successfull. The response argument is the class decoded by the ConnectionManager. The responseList argument is the class decoded as a list.
final
child Widget Function(Widget child)?
Optionally, you can specify a Widget to not be involved in api calls rebuild
final
errorBuilder Widget Function(BuildContext context, String? errorMessage)?
Optionally, a widget to manage the error state can be provided. The errorMessage argument is the error retrieved by the API call (if any). If not provided, a default error text is shown.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loaderBuilder Widget Function(BuildContext context)?
Optionally, a widget for the loading state can be provided. If null, a default black loading spinner is shown.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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