buildModalBarrier method

Widget buildModalBarrier()

Build the barrier for this ModalRoute, subclasses can override this method to create their own barrier with customized features such as color or accessibility focus size.

See also:

Implementation

Widget buildModalBarrier() {
  Widget barrier;
  if (barrierColor != null && barrierColor!.alpha != 0 && !offstage) { // changedInternalState is called if barrierColor or offstage updates
    assert(barrierColor != barrierColor!.withOpacity(0.0));
    final Animation<Color?> color = animation!.drive(
      ColorTween(
        begin: barrierColor!.withOpacity(0.0),
        end: barrierColor, // changedInternalState is called if barrierColor updates
      ).chain(CurveTween(curve: barrierCurve)), // changedInternalState is called if barrierCurve updates
    );
    barrier = AnimatedModalBarrier(
      color: color,
      dismissible: barrierDismissible, // changedInternalState is called if barrierDismissible updates
      semanticsLabel: barrierLabel, // changedInternalState is called if barrierLabel updates
      barrierSemanticsDismissible: semanticsDismissible,
    );
  } else {
    barrier = ModalBarrier(
      dismissible: barrierDismissible, // changedInternalState is called if barrierDismissible updates
      semanticsLabel: barrierLabel, // changedInternalState is called if barrierLabel updates
      barrierSemanticsDismissible: semanticsDismissible,
    );
  }

  return barrier;
}