ScopedBuilder<TStore extends BaseStore<TState>, TState>.transition constructor

ScopedBuilder<TStore extends BaseStore<TState>, TState>.transition({
  1. Key? key,
  2. TStore? store,
  3. dynamic distinct(
    1. TState
    )?,
  4. bool filter(
    1. TState
    )?,
  5. TransitionCallback? transition,
  6. Widget onError(
    1. BuildContext,
    2. dynamic
    )?,
  7. Widget onLoading(
    1. BuildContext
    )?,
  8. Widget onState(
    1. BuildContext,
    2. TState
    )?,
})

Implementation

factory ScopedBuilder.transition({
  Key? key,
  TStore? store,
  dynamic Function(TState)? distinct,
  bool Function(TState)? filter,
  TransitionCallback? transition,
  Widget Function(BuildContext, dynamic)? onError,
  Widget Function(BuildContext)? onLoading,
  Widget Function(BuildContext, TState)? onState,
}) {
  return ScopedBuilder(
    key: key,
    store: store,
    distinct: distinct,
    filter: filter,
    onState: onState == null
        ? null
        : (context, state) {
            final child = onState.call(context, state);
            if (transition != null) {
              return transition(context, child);
            } else {
              return AnimatedSwitcher(
                duration: const Duration(
                  milliseconds: 300,
                ),
                child: child,
              );
            }
          },
    onLoading: onLoading == null
        ? null
        : (context) {
            final child = onLoading.call(context);
            if (transition != null) {
              return transition(context, child);
            } else {
              return AnimatedSwitcher(
                duration: const Duration(
                  milliseconds: 300,
                ),
                child: child,
              );
            }
          },
    onError: onError == null
        ? null
        : (context, error) {
            final child = onError.call(context, error);
            if (transition != null) {
              return transition(context, child);
            } else {
              return AnimatedSwitcher(
                duration: const Duration(
                  milliseconds: 300,
                ),
                child: child,
              );
            }
          },
  );
}