ListUic<T> class
UI component that shows a list of items and controls all related states.
List UI component display a list of items using ListView widget. It requires a ListUicController object to manage its states and load data. Beside of controller you have to define a itemBuilder parameter, which is a function that creates list item widget by the item object.
Data loading
ListUic supports pull-to-refresh gesture to reload the list items. While loading, the progress indicator is displayed. If data loading failed, a snack bar with errorText message is shown.
If controller's allowPagination
property is set to true, loading data page
by page (infinite scrolling) is enabled. When user scroll the list to the end,
the next page of data is loading. The controller manages the current page to load.
During data loading the nextPageProgressView widget is displaying at the
end of the list. By default it is a circular progress indicator. You can
provide your custom progress widget for it.
Empty state
When there are no data loaded yet, 'ListUic' can show empty state views.
Default empty data view shows icon and text in the center of screen and allows user to reload the data. You can provide your own icon and/or text in emptyDataIcon and emptyDataText parameters. To use your custom view for empty data state set your widget in emptyDataView parameter.
When initial data loading is failed, the empty error view is shown. The default empty error view contains icon and text in the center of screen and allows user to reload the data. You can provide your own icon and/or text in emptyErrorIcon and emptyErrorText parameters. To use your custom view for empty error state set your widget in emptyDataView parameter.
While initial data loading, the empty progress view is displayed. Default empty progress view shows the circular progress indicator and text. You can your text for empty progress view in emptyProgressText parameter or provide your custom empty progress view in emptyProgressView parameter.
See also:
- Inheritance
Constructors
-
ListUic({Key? key, required ListUicController<
T> controller, required Widget itemBuilder(T item), Icon emptyDataIcon = const Icon(Icons.sentiment_dissatisfied, size: 96.0, color: Colors.black26), String emptyDataText = 'No results', Widget? emptyDataView, Icon emptyErrorIcon = const Icon(Icons.error_outline, size: 96.0, color: Colors.black26), String emptyErrorText = 'Error loading data', Widget? emptyErrorView, String emptyProgressText = 'Loading...', Widget? emptyProgressView, Widget? nextPageProgressView, String errorText = 'Error loading data', Color errorColor = Colors.redAccent})
Properties
-
controller
→ ListUicController<
T> -
Manages the list state
final
- emptyDataIcon → Icon
-
Icon to display in default empty data view
final
- emptyDataText → String
-
Text to display in default empty data view
final
- emptyDataView → Widget
-
View to display when the list is empty.
final
- emptyErrorIcon → Icon
-
Icon to display in default empty error view
final
- emptyErrorText → String
-
Text to display in default empty error view
final
- emptyErrorView → Widget
-
View to display when the initial data loading is failed.
final
- emptyProgressText → String
-
Text to display in default empty progress view
final
- emptyProgressView → Widget
-
View to display when the initial data loading is in progress.
final
- errorColor → Color
-
Color of the error snack bar
final
- errorText → String
-
Text to display in snack bar when data loading is failed
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- itemBuilder → Widget Function(T item)
-
Callback that returns list item widget
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- nextPageProgressView → Widget
-
View to display in the bottom of the list when next page of data is loading.
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}) → 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