resolve method

  1. @override
Widget resolve(
  1. Set<WidgetEvent> events
)
override

Returns a value of type T that depends on events.

Widgets like TextButton and ElevatedButton apply this method to their current WidgetEvents to compute colors and other visual parameters at build time.

Implementation

@override
Widget resolve(events) {
  Widget result = super.resolve(events);

  return Builder(builder: (context) {
    final theme = DrivenSwitcherTheme.of(context);
    final themeMaintainKey = maintainKey ?? theme.maintainKey;
    final themeDuration = duration ?? theme.duration;
    final themeReverseDuration = reverseDuration ?? theme.reverseDuration;
    final themeSwitchInCurve = switchInCurve ?? theme.switchInCurve;
    final themeSwitchOutCurve = switchOutCurve ?? theme.switchOutCurve;
    final themeTransitionBuilder =
        transitionBuilder ?? theme.transitionBuilder;
    final themeLayoutBuilder = layoutBuilder ?? theme.layoutBuilder;

    if (themeMaintainKey) {
      result = KeyedSubtree(
        key: ValueKey('DrivenSwitcher(${events.toString()})'),
        child: result,
      );
    }
    return AnimatedSwitcher(
      duration: themeDuration ?? defaultDuration,
      reverseDuration: themeReverseDuration,
      switchInCurve: themeSwitchInCurve ?? Curves.linear,
      switchOutCurve:
          themeSwitchOutCurve ?? themeSwitchInCurve ?? Curves.linear,
      transitionBuilder: themeTransitionBuilder ?? defaultTransitionBuilder,
      layoutBuilder: themeLayoutBuilder ?? defaultLayoutBuilder,
      child: result,
    );
  });
}