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.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
    );
    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,
    );
  }
}