PaginatedApiCallBuilder<T extends Decodable, E extends Decodable> class
This widget helps to manage transparently a paginated 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.
Furthermore, it can manage pagination while scrolling.
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
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- PaginatedApiCallBuilder
Constructors
-
PaginatedApiCallBuilder({Key? key, required PaginatedAPIRequest<
T, E> apiCall, required Widget builder(BuildContext context, List<T> ? response), Widget loaderBuilder(BuildContext context)?, Widget errorBuilder(BuildContext context, String? errorMessage)?, Map<String, String> ? initialQuery, Widget emptyDataBuilder(BuildContext context)?, int initialPage = 0}) -
This widget helps to manage transparently a paginated 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
→ PaginatedAPIRequest<
T, E> -
The api call to retrieve paginated data. The ConnectionManager's
doApiRequest
method can be used to retrieve a single response, that then must be converted to a PaginatedAPIResponse type.final -
builder
→ Widget Function(BuildContext context, List<
T> ? response) -
The builder for a widget when the API call is successfull.
The
response
argument is the class decoded by the ConnectionManager.final - emptyDataBuilder → Widget Function(BuildContext context)?
-
Optionally, a widget to manage the empty state can be provided. If not provided,
the
builder
will be used.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
- initialPage → int
-
The initial page for pagination. Usually pagination starts from 0 (default value),
but a different number can be specified to be used as first page.
final
-
initialQuery
→ Map<
String, String> ? -
Optionally, a query for the api calls can be set as default.
It can be overriden when calling
startApiCall
directly or when initializing the ScrollController.final - 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