JsonSchemaBloc class
Bloc
for managing JsonSchemaState
through the use of JsonSchemaEvent
which implements ClickListener
used to handle the click event of
controls.
This is the business logic used to manage the form.
- Inheritance
-
- Object
- Stream<
JsonSchemaState> - JsonSchemaBloc
- Implemented types
-
- ClickListener
Constructors
- JsonSchemaBloc({@required BuildContext formContext, VoidCallback onFormChanged, WillPopCallback onFormWillPop })
-
Create a JsonSchemaBloc
using
formContext
and optionallyonFormChanged
andonFormWillPop
.
Properties
- formContext ↔ BuildContext
-
Property used to store
BuildContext
used if you need to retrieve form state through context. [...]read / write -
formKey
→ GlobalKey<
FormState> -
Get to the
FormState
.read-only - initialState → JsonSchemaState
-
Returns the state before any
events
have been added.read-only - onFormChanged ↔ VoidCallback
-
Property used to store
VoidCallback
that will be used to handle the Form.onFormChanged event.read / write - onFormWillPop ↔ WillPopCallback
-
Property used to store
WillPopCallback
that will be used to handle the Form.onFormWillPop event.read / write -
submitData
→ Stream<
String> -
Get to the
Stream
<String
> of the submit data.read-only -
first
→ Future<
JsonSchemaState> -
The first element of this stream. [...]
read-only, inherited
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- isBroadcast → bool
-
Returns whether the
Stream<State>
is a broadcast stream.read-only, inherited -
isEmpty
→ Future<
bool> -
Whether this stream contains any elements. [...]
read-only, inherited
-
last
→ Future<
JsonSchemaState> -
The last element of this stream. [...]
read-only, inherited
-
length
→ Future<
int> -
The number of elements in this stream. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
-
single
→ Future<
JsonSchemaState> -
The single element of this stream. [...]
read-only, inherited
- state → JsonSchemaState
-
Returns the current state of
the
bloc
.read-only, inherited
Methods
-
close(
) → Future< void> -
Closes the
event
andstate
Streams
. This method should be called when abloc
is no longer needed. Once close is called,events
that are added will not be processed and will result in an error being passed to onError. In addition, if close is called whileevents
are still being processed, thebloc
will continue to process the pendingevents
to completion. -
getFieldStream(
String fieldName) → Stream -
Get
Stream
<dynamic
> for the form'sfieldName
field. -
getFormData(
) → String -
Get JSON
String
for form data after validate. -
getPropertySchema(
String fieldName) → JsonSchema -
Get
JsonSchema
from thefieldName
property ofdataSchema
present in the current state. -
mapEventToState(
JsonSchemaEvent event) → Stream< JsonSchemaState> -
Must be implemented when a class extends
bloc
. Takes the incomingevent
as the argument. mapEventToState is called whenever anevent
is added. mapEventToState must convert thatevent
into a new state and return the new state in the form of aStream<State>
. -
onClicked(
String event) → void -
override
-
validate(
) → bool -
Validate form data using
JsonSchema
-
add(
JsonSchemaEvent event) → void -
Notifies the
bloc
of a newevent
which triggers mapEventToState. If close has already been called, any subsequent calls to add will be delegated to the onError method which can be overriden at thebloc
as well as theBlocDelegate
level.inherited -
any(
bool test(T element)) → Future< bool> -
Checks whether
test
accepts any element provided by this stream. [...]inherited -
asBroadcastStream(
{void onListen(StreamSubscription< T> subscription), void onCancel(StreamSubscription<T> subscription) }) → Stream<JsonSchemaState> -
Returns a multi-subscription stream that produces the same events as this. [...]
inherited
-
asyncExpand<
E> (Stream< E> convert(T event)) → Stream<E> -
Transforms each element into a sequence of asynchronous events. [...]
inherited
-
asyncMap<
E> (FutureOr< E> convert(T event)) → Stream<E> -
Creates a new stream with each data event of this stream asynchronously
mapped to a new event. [...]
inherited
-
cast<
R> () → Stream< R> -
Adapt this stream to be a
Stream<R>
. [...]inherited -
contains(
Object needle) → Future< bool> -
Returns whether
needle
occurs in the elements provided by this stream. [...]inherited -
distinct(
[bool equals(T previous, T next) ]) → Stream< JsonSchemaState> -
Skips data events if they are equal to the previous data event. [...]
inherited
-
drain<
E> ([E futureValue ]) → Future< E> -
Discards all data on this stream, but signals when it is done or an error
occurred. [...]
inherited
-
elementAt(
int index) → Future< JsonSchemaState> -
Returns the value of the
index
th data event of this stream. [...]inherited -
every(
bool test(T element)) → Future< bool> -
Checks whether
test
accepts all elements provided by this stream. [...]inherited -
expand<
S> (Iterable< S> convert(T element)) → Stream<S> -
Transforms each element of this stream into a sequence of elements. [...]
inherited
-
firstWhere(
bool test(T element), { JsonSchemaState orElse() }) → Future< JsonSchemaState> -
Finds the first element of this stream matching
test
. [...]inherited -
fold<
S> (S initialValue, S combine(S previous, T element)) → Future< S> -
Combines a sequence of values by repeatedly applying
combine
. [...]inherited -
forEach(
void action(T element)) → Future -
Executes
action
on each element of this stream. [...]inherited -
handleError(
Function onError, { bool test(dynamic error) }) → Stream< JsonSchemaState> -
Creates a wrapper Stream that intercepts some errors from this stream. [...]
inherited
-
join(
[String separator = "" ]) → Future< String> -
Combines the string representation of elements into a single string. [...]
inherited
-
lastWhere(
bool test(T element), { JsonSchemaState orElse() }) → Future< JsonSchemaState> -
Finds the last element in this stream matching
test
. [...]inherited -
listen(
void onData(State value), { Function onError, void onDone(), bool cancelOnError }) → StreamSubscription< JsonSchemaState> -
Adds a subscription to the
Stream<State>
. Returns aStreamSubscription
which handles events from theStream<State>
using the providedonData
,onError
andonDone
handlers.inherited -
map<
S> (S convert(T event)) → Stream< S> -
Transforms each element of this stream into a new stream event. [...]
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
onError(
Object error, StackTrace stacktrace) → void -
Called whenever an
error
is thrown within mapEventToState. By default allerror
s will be ignored andbloc
functionality will be unaffected. Thestacktrace
argument may benull
if the state stream received an error without astacktrace
. A great spot to handle errors at the individualBloc
level.inherited -
onEvent(
JsonSchemaEvent event) → void -
Called whenever an
event
is added to thebloc
. A great spot to add logging/analytics at the individualbloc
level.inherited -
onTransition(
Transition< JsonSchemaEvent, JsonSchemaState> transition) → void -
Called whenever a
transition
occurs with the giventransition
. Atransition
occurs when a newevent
is added and mapEventToState executed. onTransition is called before abloc
's state has been updated. A great spot to add logging/analytics at the individualbloc
level.inherited -
pipe(
StreamConsumer< JsonSchemaState> streamConsumer) → Future -
Pipes the events of this stream into
streamConsumer
. [...]inherited -
reduce(
JsonSchemaState combine(T previous, T element)) → Future< JsonSchemaState> -
Combines a sequence of values by repeatedly applying
combine
. [...]inherited -
singleWhere(
bool test(T element), { JsonSchemaState orElse() }) → Future< JsonSchemaState> -
Finds the single element in this stream matching
test
. [...]inherited -
skip(
int count) → Stream< JsonSchemaState> -
Skips the first
count
data events from this stream. [...]inherited -
skipWhile(
bool test(T element)) → Stream< JsonSchemaState> -
Skip data events from this stream while they are matched by
test
. [...]inherited -
take(
int count) → Stream< JsonSchemaState> -
Provides at most the first
count
data events of this stream. [...]inherited -
takeWhile(
bool test(T element)) → Stream< JsonSchemaState> -
Forwards data events while
test
is successful. [...]inherited -
timeout(
Duration timeLimit, { void onTimeout(EventSink< T> sink) }) → Stream<JsonSchemaState> -
Creates a new stream with the same events as this stream. [...]
inherited
-
toList(
) → Future< List< JsonSchemaState> > -
Collects all elements of this stream in a
List
. [...]inherited -
toSet(
) → Future< Set< JsonSchemaState> > -
Collects the data of this stream in a
Set
. [...]inherited -
toString(
) → String -
Returns a string representation of this object.
inherited
-
transform<
S> (StreamTransformer< JsonSchemaState, S> streamTransformer) → Stream<S> -
Applies
streamTransformer
to this stream. [...]inherited -
transformEvents(
Stream< JsonSchemaEvent> events, Stream<JsonSchemaState> next(Event event)) → Stream<JsonSchemaState> -
Transforms the
events
stream along with anext
function into aStream<State>
. Events that should be processed by mapEventToState need to be passed tonext
. By defaultasyncExpand
is used to ensure allevents
are processed in the order in which they are received. You can override transformEvents for advanced usage in order to manipulate the frequency and specificity with which mapEventToState is called as well as whichevents
are processed. [...]inherited -
transformStates(
Stream< JsonSchemaState> states) → Stream<JsonSchemaState> -
Transforms the
Stream<State>
into a newStream<State>
. By default transformStates returns the incomingStream<State>
. You can override transformStates for advanced usage in order to manipulate the frequency and specificity at whichtransitions
(state changes) occur. [...]inherited -
where(
bool test(T event)) → Stream< JsonSchemaState> -
Creates a new stream from this stream that discards some elements. [...]
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited