StreamWorker<T> constructor
const
StreamWorker<T> ({
- Key? key,
- required Stream<
T> stream, - required Widget builder(
- BuildContext context,
- T data
- bool isProd = false,
- T? initialData,
- Widget emptyBuilder(
- BuildContext context
- Widget errorBuilder(
- BuildContext context,
- Object? error
- Widget loadingBuilder(
- BuildContext context
Creates a StreamWorker that listens to the provided stream and builds
the user interface according to its state.
stream: The data stream to listen to. The stream subscription is automatically managed by StreamBuilder - it will be cancelled when the widget is disposed. For StreamController instances, ensure proper cleanup by closing them when done.builder: Called when non-null data is available.isProd: Production mode flag. Whentrue, hides the default empty state widget (shows nothing instead of OptionEmpty) when data is null. Useful for production environments where empty states should be minimal. Default:false.initialData: Optional initial snapshot value used while awaiting the first event.emptyBuilder: Builder used when the data is null or empty.errorBuilder: Builder used when an error occurs.loadingBuilder: Builder used while the stream is loading.
Implementation
const StreamWorker({
super.key,
required this.stream,
required this.builder,
this.isProd = false,
this.initialData,
this.emptyBuilder,
this.errorBuilder,
this.loadingBuilder,
});