getVerticalOffset static method

double getVerticalOffset({
  1. required BuildContext context,
  2. BrnToastGravity? gravity,
  3. double? verticalOffset,
})

获取默认设置的垂直间距

Implementation

static double getVerticalOffset({
  required BuildContext context,
  BrnToastGravity? gravity,
  double? verticalOffset,
}) {
  final double offset = verticalOffset ?? 0;
  final double defaultOffset;
  switch (gravity) {
    case BrnToastGravity.bottom:
      final offset = verticalOffset ?? _defaultBottomOffset;
      defaultOffset = MediaQuery.of(context).viewInsets.bottom + offset;
      break;
    case BrnToastGravity.top:
      final offset = verticalOffset ?? _defaultTopOffset;
      defaultOffset = MediaQuery.of(context).viewInsets.top + offset;
      break;
    case BrnToastGravity.center:
    default:
      defaultOffset = verticalOffset ?? 0;
  }

  return defaultOffset + offset;
}