isolate_bloc library

Classes

IIsolateFactory
Abstract factory which is used to create and initialize IIsolateWrapper and IIsolateMessenger.
IIsolateWrapper
Abstract layer for Isolate.
InitializerException
This exception indicates that some exception was thrown in Initializer function.
IsolateBloc<Event, State>
Takes a Stream of Events as input and transforms them into a Stream of States as output.
IsolateBlocBase<Event, State>
An interface for the core functionality implemented by both IsolateCubit and IsolateBloc.
IsolateBlocBuilder<B extends IsolateBlocBase<Object?, S>, S>
IsolateBlocBuilder handles building a widget in response to new states. IsolateBlocBuilder is analogous to StreamBuilder but has simplified API to reduce the amount of boilerplate code needed as well as bloc-specific performance improvements. Please refer to IsolateBlocListener if you want to "do" anything in response to state changes such as navigation, showing a dialog, etc...
IsolateBlocBuilderBase<B extends IsolateBlocBase<Object?, S>, S>
Base class for widgets that build themselves based on interaction with a specified bloc.
IsolateBlocConsumer<B extends IsolateBlocBase<Object?, S>, S>
IsolateBlocConsumer exposes a builder and listener in order react to new states. IsolateBlocConsumer is analogous to a nested IsolateBlocListener and IsolateBlocBuilder but reduces the amount of boilerplate needed. IsolateBlocConsumer should only be used when it is necessary to both rebuild UI and execute other reactions to state changes in the bloc.
IsolateBlocListener<B extends IsolateBlocBase<Object?, S>, S>
Takes a BlocWidgetListener and an optional bloc and invokes the listener in response to state changes in the bloc. It should be used for functionality that needs to occur only in response to a state change such as navigation, showing a SnackBar, showing a Dialog, etc... The listener is guaranteed to only be called once for each state change unlike the builder in BlocBuilder.
IsolateBlocListenerBase<B extends IsolateBlocBase<Object?, S>, S>
Base class for widgets that listen to state changes in a specified bloc.
IsolateBlocObserver
An interface for observing the behavior of IsolateBloc and IsolateCubit instances.
IsolateBlocProvider<T extends IsolateBlocBase<Object?, State>, State>
Takes a ValueBuilder that is responsible for creating the bloc and a child which will have access to the bloc via IsolateBlocProvider.of(context). It is used as a dependency injection (DI) widget so that a single instance of a bloc can be provided to multiple widgets within a subtree.
IsolateBlocSelector<B extends IsolateBlocBase<Object?, S>, S, T>
IsolateBlocSelector is analogous to IsolateBlocBuilder but allows developers to filter updates by selecting a new value based on the bloc state. Unnecessary builds are prevented if the selected value does not change.
IsolateBlocWrapper<State>
Takes a Stream of Events as input and transforms them into a Stream of States as output using IsolateBlocBase.
IsolateCreateResult
IsolateCubit<Event, State>
Takes a Stream of Events as input and transforms them into a Stream of States as output.
IsolateInitializer
Initializer which is used to create Isolate and initialize UIIsolateManager and IsolateManager.
IsolateManager
Manager which works in Isolate, respond on IsolateBlocEvents from UI Isolate, manages IsolateBlocBases and implements register and getBloc functions.
MultiIsolateBlocProvider
Merges multiple IsolateBlocProvider widgets into one widget tree.
Transition<Event, State>
Occurs when an event is added after onEventReceived has been called but before the bloc's State has been updated. A Transition consists of the currentState, the event which was added, and the nextState.
UIIsolateManager
Manager which is works in UI Isolate, responds on IsolateBlocEvents from Isolate, manages IsolateBlocWrappers and implements createBloc global function.

Mixins

IsolateBlocListenerSingleChildWidget
Mixin which allows MultiIsolateBlocListener to infer the types of multiple IsolateBlocListeners.
IsolateBlocProviderSingleChildWidget
Mixin which allows MultiBlocProvider to infer the types of multiple IsolateBlocProviders.

Extensions

IsolateBlocProviderExtension on BuildContext
Extends the BuildContext class with the ability to perform a lookup based on a IsolateBlocBase type.

Properties

isolateBlocIdGenerator IdGenerator
This function is used to generate id for IsolateBlocWrapper.
getter/setter pair

Functions

createBloc<B extends IsolateBlocBase<Object?, S>, S>() IsolateBlocWrapper<S>
Starts creating IsolateBlocBase and returns IsolateBlocWrapper.
getBloc<B extends IsolateBlocBase<Object, S>, S>() IsolateBlocWrapper<S>
Use this function to communicate with IsolateBlocBase in Isolate.
initialize(Initializer userInitializer, {MethodChannelSetup methodChannelSetup = const MethodChannelSetup()}) Future<void>
Initializes UIIsolateManager and IsolateManager in Isolate and runs userInitializer.
register<T extends IsolateBlocBase<Object?, S>, S>({required IsolateBlocCreator<Object?, S> create, S? initialState}) → void
Registers IsolateBlocBase. This allows you to create it in UI Isolate using createBloc function.

Typedefs

BlocBuilderCondition<S> = bool Function(S previous, S current)
Signature for the buildWhen function which takes the previous state and the current state and is responsible for returning a bool which determines whether to rebuild IsolateBlocBuilder with the current state.
BlocWidgetBuilder<S> = Widget Function(BuildContext context, S state)
Signature for the builder function which takes the BuildContext and state and is responsible for returning a widget which is to be rendered. This is analogous to the builder function in StreamBuilder.
BlocWidgetListener<S> = void Function(BuildContext context, S state)
Signature for the listener function which takes the BuildContext along with the state and is responsible for executing in response to state changes.
BlocWidgetSelector<S, T> = T Function(S state)
Signature for the selector function which is responsible for returning a selected value, T, based on state.
CreateIsolateBloc<T extends IsolateBlocBase<Object?, Object?>> = T Function(BuildContext context)
A function that creates a Bloc of type T.
EventReceiver = void Function(Object? event)
Signature for event receiver function which takes an IsolateBlocTransitionEvent and send this event to the IsolateBloc
IdGenerator = String Function()
Signature for IsolateBlocWrapper id generator.
Initializer = FutureOr Function()
Signature for initialization function which would be run in Isolate to initialize your blocs and repository. Initializer must be a global or static function.
InitialStates = Map<Type, Object?>
Signature for map with IsolateBlocBases and their initial states.
IsolateBlocCreator<E, S> = IsolateBlocBase<E, S> Function()
Signature for function which creates IsolateBlocBase.
IsolateBlocKiller = void Function(String uuid)
Signature for function which takes IsolateBloc's uuid and close it
IsolateBlocListenerCondition<S> = bool Function(S previous, S current)
Signature for the listenWhen function which takes the previous state and the current state and is responsible for returning a bool which determines whether or not to call BlocWidgetListener of IsolateBlocListener with the current state.
IsolateRun = FutureOr<void> Function(IIsolateMessenger messenger, Initializer initializer)
Signature for function which will run in Isolate.
TransitionFunction<Event, State> = Stream<Transition<Event, State>> Function(Event)
Signature for a mapper function which takes an Event as input and outputs a Stream of Transition objects.

Exceptions / Errors

BlocUnhandledErrorException
This is an exception which is thrown on exception in add function in debug mode
BlocUnregisteredException
This exception indicates that bloc wasn't registered.
IsolateManagerUnInitialized
This exception indicates that IsolateManager isn't initialized.
UIIsolateManagerUnInitialized
This exception indicates that initialize function wasn't called.