buildModalBarrier method
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:
- ModalBarrier, which is typically used to build a barrier.
- ModalBottomSheetRoute, which overrides this method to build a customized barrier.
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;
}