DataSync<T extends DataStore> class

A widget that builds its descendants based on the state of a DataStore.

Example:

DataSync<MyStore>(
  builder: (context, tank) {
    //= Build UI based on tank and status
  },
  customLoadingBuilder: (context) {
    return Center(child: CircularProgressIndicator());
  },
  customErrorBuilder: (context, error) {
    return Center(child: Text('An error occurred: $error'));
  },
  enableDefaultWidgets: true,
  disableDefaultErrorWidget: false,
  disableDefaultLoadingWidget: false,
)
Inheritance

Constructors

DataSync({required Widget builder(BuildContext context, T store, bool hasActionExecuted), required Set<Type>? actions, Widget customLoadingBuilder(BuildContext context)?, Widget customErrorBuilder(BuildContext context, String error)?, Map<Type, ContextCallbackWithStatus>? actionNotifier, bool enableDefaultWidgets = false, bool disableDefaultErrorWidget = false, bool disableDefaultLoadingWidget = false, Key? key})
Creates a new DataSync instance.
const

Properties

actionNotifier Map<Type, ContextCallbackWithStatus>?
A map of DataAction actions to be notified.
final
actions Set<Type>?
The actions to listen to.
final
builder Widget Function(BuildContext context, T store, bool hasActionExecuted)
The widget builder for rendering data.
final
customErrorBuilder Widget Function(BuildContext context, String error)?
A custom builder function for the error state widget. If enableDefaultWidgets is true, this will override the default error widget. Example:
final
customLoadingBuilder Widget Function(BuildContext context)?
A custom builder function for the loading state widget. If enableDefaultWidgets is true, this will override the default loading widget.
final
disableDefaultErrorWidget bool
Whether to disable the default error widget. Only applicable if enableDefaultWidgets is true and no custom error builder is provided.
final
disableDefaultLoadingWidget bool
Whether to disable the default loading widget. Only applicable if enableDefaultWidgets is true and no custom loading builder is provided.
final
enableDefaultWidgets bool
Whether to enable default loading and error widgets. If true, default widgets will be used unless overridden by custom builders. Defaults to false.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() DataSyncState<DataStore>
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}) 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