When you need to intercept the Android back-button, you usually add WillPopScope to your
widget tree. However, under some use cases, specially when developing stateful widgets that
interact with the back button, it's more convenient to use the BackButtonInterceptor.
BlocBuilder handles building a widget in response to new states.
BlocBuilder 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 BlocListener if you want to "do" anything in response to
state changes such as navigation, showing a dialog, etc...
BlocConsumer exposes a builder and listener in order react to new
states.
BlocConsumer is analogous to a nested BlocListener
and BlocBuilder but reduces the amount of boilerplate needed.
BlocConsumer should only be used when it is necessary to both rebuild UI
and execute other reactions to state changes in the bloc.
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.
Takes a create function that is responsible for
creating the Bloc or Cubit and a child which will have access
to the instance via BlocProvider.of(context).
It is used as a dependency injection (DI) widget so that a single instance
of a Bloc or Cubit can be provided to multiple widgets within a subtree.
BlocSelector is analogous to BlocBuilder 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.
annotation to define a custom parameter decoder/encoder
this is useful when the is encoded/decoded in a non-standard way like base64Url
this must be used as an annotation on a field
A BlocObserver which supports registering multiple BlocObserver
instances. This is useful when maintaining multiple BlocObserver instances
for different functions e.g. LoggingBlocObserver,
ErrorReportingBlocObserver.
Takes a create function that is responsible for creating the repository
and a child which will have access to the repository via
RepositoryProvider.of(context).
It is used as a dependency injection (DI) widget so that a single instance
of a repository can be provided to multiple widgets within a subtree.
Your functions can also process information about routes by using the function's RouteInfo info
parameter. To get the current route in the navigator, call info.currentRoute(context).
Also, info.routeWhenAdded contains the route that was the current one when the interceptor
was added through the BackButtonInterceptor.add() method.
Lexicographically sortable, 128-bit identifier (UUID) with 48-bit timestamp
and 80 random bits. Canonically encoded as a 26 character string, as opposed
to the 36 character UUID.
Used to annotate a function f. Indicates that f always throws an
exception. Any functions that override f, in class inheritance, are also
expected to conform to this contract.
Used to annotate a Future-returning function (including constructors,
getters, methods, and operators), or a Future-typed field (including
top-level, instance, and static) f. Indicates that the Future value that
f returns does not need to be awaited. Any methods that override f in
class inheritance, are also expected to conform to this contract.
Used to annotate a method, getter, top-level function, or top-level getter
to indicate that the value obtained by invoking it should not be stored in a
field or top-level variable. The annotation can also be applied to a class
to implicitly annotate all of the valid members of the class, or applied to
a library to annotate all of the valid members of the library, including
classes. If a value returned by an element marked as doNotStore is
returned from a function or getter, that function or getter should be
similarly annotated.
Used to annotate an optional parameter, method, getter or top-level getter
or function that is not intended to be accessed in checked-in code, but
might be ephemerally used during development or local testing.
Used to annotate a library, or any declaration that is part of the public
interface of a library (such as top-level members, class members, and
function parameters) to indicate that the annotated API is experimental and
may be removed or changed at any-time without updating the version of the
containing package, despite the fact that it would otherwise be a breaking
change.
Used to annotate an instance or static method m. Indicates that m must
either be abstract or must return a newly allocated object or null. In
addition, every method that either implements or overrides m is implicitly
annotated with this same annotation.
Used to annotate a declaration which should only be used from within the
package in which it is declared, and which should not be exposed from said
package's public API.
Used to annotate a const constructor c. Indicates that any invocation of
the constructor must use the keyword const unless one or more of the
arguments to the constructor is not a compile-time constant.
Used to annotate an instance member (method, getter, setter, operator, or
field) m. Indicates that every invocation of a member that overrides m
must also invoke m. In addition, every method that overrides m is
implicitly annotated with this same annotation.
Used to annotate an instance member (method, getter, setter, operator, or
field) m in a class C or mixin M. Indicates that m should not be
overridden in any classes that extend or mixin C or M.
Used to annotate a class, mixin, extension, function, method, or typedef
declaration C. Indicates that any type arguments declared on C are to
be treated as optional.
Used to annotate an instance member in a class or mixin which is meant to
be visible only within the declaring library, and to other instance members
of the class or mixin, and their subtypes.
Used to annotate a named parameter p in a method or function f.
Indicates that every invocation of f must include an argument
corresponding to p, despite the fact that p would otherwise be an
optional parameter.
Used to annotate a method, field, or getter within a class, mixin, or
extension, or a or top-level getter, variable or function to indicate that
the value obtained by invoking it should be used. A value is considered used
if it is assigned to a variable, passed to a function, or used as the target
of an invocation, or invoked (if the result is itself a function).
Used to annotate an instance member that was made public so that it could be
overridden but that is not intended to be referenced from outside the
defining library.
Helper function used in generated fromJson code when
JsonSerializable.disallowUnrecognizedKeys is true for an annotated type or
JsonKey.required is true for any annotated fields.
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 BlocBuilder with the current state.
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 BlocListener
with the current 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.