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
@override
Widget buildModalBarrier() {
if (barrierColor.alpha != 0 && !offstage) {
// 如果 barrierColor 或 offstage 更新,则调用 changedInternalState
assert(barrierColor != barrierColor.withOpacity(0.0));
final Animation<Color?> color = animation!.drive(
ColorTween(
begin: barrierColor.withOpacity(0.0),
end: barrierColor, // 如果 barrierColor 更新,则调用 changedInternalState
).chain(
CurveTween(curve: barrierCurve),
), // 如果 barrierCurve 更新,则调用 changedInternalState
);
return AnimatedModalBarrier(
color: color,
dismissible: barrierDismissible,
// 如果 barrierDismissible 更新,则调用 changedInternalState
semanticsLabel: barrierLabel,
// 如果 barrierLabel 更新,则调用 changedInternalState
barrierSemanticsDismissible: semanticsDismissible,
clipDetailsNotifier: _clipDetailsNotifier,
semanticsOnTapHint: barrierOnTapHint,
);
} else {
return ModalBarrier(
dismissible: barrierDismissible,
// 如果 barrierDismissible 更新,则调用 changedInternalState
semanticsLabel: barrierLabel,
// 如果 barrierLabel 更新,则调用 changedInternalState
barrierSemanticsDismissible: semanticsDismissible,
clipDetailsNotifier: _clipDetailsNotifier,
semanticsOnTapHint: barrierOnTapHint,
);
}
}