buildModalBarrier method

  1. @override
Widget buildModalBarrier()
override

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

@override
Widget buildModalBarrier() {
  if (barrierColor.a != 0 && !offstage) {
    // changedInternalState is called if barrierColor or offstage updates
    final color = animation!.drive(
      ColorTween(
        begin: barrierColor.withValues(alpha: 0.0),
        end: barrierColor, // changedInternalState is called if barrierColor updates
      ).chain(CurveTween(curve: barrierCurve)), // changedInternalState is called if barrierCurve updates
    );
    return AnimatedModalBarrier(
      color: color,
      dismissible: barrierDismissible, // changedInternalState is called if barrierDismissible updates
      semanticsLabel: barrierLabel, // changedInternalState is called if barrierLabel updates
      barrierSemanticsDismissible: semanticsDismissible,
      clipDetailsNotifier: _clipDetailsNotifier,
      semanticsOnTapHint: barrierOnTapHint,
    );
  } else {
    return ModalBarrier(
      dismissible: barrierDismissible, // changedInternalState is called if barrierDismissible updates
      semanticsLabel: barrierLabel, // changedInternalState is called if barrierLabel updates
      barrierSemanticsDismissible: semanticsDismissible,
      clipDetailsNotifier: _clipDetailsNotifier,
      semanticsOnTapHint: barrierOnTapHint,
    );
  }
}