RenderToggleable constructor

RenderToggleable({@required bool value, bool tristate: false, @required Color activeColor, @required Color inactiveColor, ValueChanged<bool> onChanged, BoxConstraints additionalConstraints, @required TickerProvider vsync })

Creates a toggleable render object.

The activeColor, and inactiveColor arguments must not be null. The value can only be null if tristate is true.

Implementation

RenderToggleable({
  @required bool value,
  bool tristate = false,
  @required Color activeColor,
  @required Color inactiveColor,
  ValueChanged<bool> onChanged,
  BoxConstraints additionalConstraints,
  @required TickerProvider vsync,
}) : assert(tristate != null),
     assert(tristate || value != null),
     assert(activeColor != null),
     assert(inactiveColor != null),
     assert(vsync != null),
     _value = value,
     _tristate = tristate,
     _activeColor = activeColor,
     _inactiveColor = inactiveColor,
     _onChanged = onChanged,
     _vsync = vsync,
     super(additionalConstraints: additionalConstraints) {
  _tap = TapGestureRecognizer()
    ..onTapDown = _handleTapDown
    ..onTap = _handleTap
    ..onTapUp = _handleTapUp
    ..onTapCancel = _handleTapCancel;
  _positionController = AnimationController(
    duration: _kToggleDuration,
    value: value == false ? 0.0 : 1.0,
    vsync: vsync,
  );
  _position = CurvedAnimation(
    parent: _positionController,
    curve: Curves.linear,
  )..addListener(markNeedsPaint)
   ..addStatusListener(_handlePositionStateChanged);
  _reactionController = AnimationController(
    duration: kRadialReactionDuration,
    vsync: vsync,
  );
  _reaction = CurvedAnimation(
    parent: _reactionController,
    curve: Curves.fastOutSlowIn,
  )..addListener(markNeedsPaint);
}